Skip to content

Commit b0acbff

Browse files
committed
fix console readin
1 parent 4b62956 commit b0acbff

5 files changed

+59
-25
lines changed

shioricaller.vcxproj

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
113113
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
114114
<StringPooling>true</StringPooling>
115+
<BuildStlModules>false</BuildStlModules>
115116
</ClCompile>
116117
<Link>
117118
<SubSystem>Console</SubSystem>
@@ -151,6 +152,7 @@
151152
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
152153
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
153154
<StringPooling>true</StringPooling>
155+
<BuildStlModules>false</BuildStlModules>
154156
</ClCompile>
155157
<Link>
156158
<SubSystem>Console</SubSystem>

shioricaller.vcxproj.user

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<PropertyGroup />
3+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
4+
<LocalDebuggerCommandArguments>E:\ssp\ghost\Taromati2\ghost\master\shiori\aya.dll</LocalDebuggerCommandArguments>
5+
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
6+
</PropertyGroup>
7+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
8+
<LocalDebuggerCommandArguments>E:\ssp\ghost\Taromati2\ghost\master\shiori\aya.dll</LocalDebuggerCommandArguments>
9+
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
10+
</PropertyGroup>
11+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
12+
<LocalDebuggerCommandArguments>E:\ssp\ghost\Taromati2\ghost\master\shiori\aya.dll</LocalDebuggerCommandArguments>
13+
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
14+
</PropertyGroup>
15+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
16+
<LocalDebuggerCommandArguments>E:\ssp\ghost\Taromati2\ghost\master\shiori\aya.dll</LocalDebuggerCommandArguments>
17+
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
18+
</PropertyGroup>
419
</Project>

src/_gists.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#include "my-gists/ukagaka/shiori_loader.cpp"
22
#include "my-gists/ukagaka/protocol_message.cpp"
3-
#include "my-gists/windows/GenerateDump.cpp"
43
#include "my-gists/windows/EnableVirtualTerminal.cpp"
4+
#include "my-gists/windows/small_io.cpp"

src/shioricaller.cpp

+39-22
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,28 @@
33

44
#include "my-gists/ukagaka/shiori_loader.hpp"
55
#include "my-gists/ukagaka/protocol_message.hpp"
6-
#include "my-gists/windows/GenerateDump.hpp"
76
#include "my-gists/windows/EnableVirtualTerminal.hpp"
7+
#include "my-gists/windows/small_io.hpp"
88
#include "my-gists/ansi_color.hpp"
9-
#include <iostream>
9+
1010
#include <string>
1111

1212
int wmain(int argc, wchar_t* argv[]){
13-
InstallExceptionFilter();
1413
EnableVirtualTerminal();//for color output
1514

1615
if(argc != 2) {
17-
std::cout << "Usage 1: \t" GREEN_TEXT("shioricaller shiori.dll < request.txt > response.txt") << std::endl
18-
<< "Usage 2: \t" GREEN_TEXT("shioricaller shiori.dll") << std::endl
19-
<< "(In Usage 2, you need to:" << std::endl
20-
<< "\t1. input request manually" << std::endl
21-
<< "\t2. press Enter*2 to send request" << std::endl
22-
<< "\t3. when you want to quit, press Ctrl+Z or something to send EOF" << std::endl
23-
<< ")" << std::endl;
16+
out << "Usage 1: \t" GREEN_TEXT("shioricaller shiori.dll < request.txt > response.txt") "\n"
17+
"Usage 2: \t" GREEN_TEXT("shioricaller shiori.dll") "\n"
18+
"(In Usage 2, you need to:" "\n"
19+
"\t1. input request manually" "\n"
20+
"\t2. press Enter*2 to send request" "\n"
21+
"\t3. when you want to quit, press Ctrl+Z or something to send EOF" "\n"
22+
")" "\n";
2423
return 0;
2524
}
2625

27-
auto error_handler = [](Cshiori::Error err) {
28-
std::cerr << RED_OUTPUT("Error: " << to_ansi_colored_string(err)) << std::endl;
26+
auto error_handler = [](Cshiori::Error aerr) {
27+
err << RED_OUTPUT("Error: " << to_ansi_colored_string(aerr)) << endline;
2928
};
3029

3130
Cshiori shiori{
@@ -37,16 +36,34 @@ int wmain(int argc, wchar_t* argv[]){
3736

3837
if(not shiori.All_OK())
3938
return 1;
40-
41-
std::string req_buf,req_line;
42-
while(1) {
43-
std::getline(std::cin, req_line);
44-
if(std::cin.eof())break;
45-
req_buf += req_line + "\r\n";
46-
if(req_line.empty()) {
47-
const auto ret = ukagaka::protocol_message{shiori(req_buf)};
48-
std::cout << to_ansi_colored_string(ret);
49-
req_buf.clear();
39+
if(in.is_console()) {
40+
std::wstring req_buf, req_line;
41+
while(1) {
42+
getline(in, req_line);
43+
if(!in)
44+
break;
45+
req_buf += req_line + L"\r\n";
46+
if(req_line.empty()) {
47+
const auto request = ukagaka::protocol_message{req_buf};
48+
const auto code_cvted_request = std::string(request);
49+
const auto ret = ukagaka::protocol_message{shiori(code_cvted_request)};
50+
out << to_ansi_colored_wstring(ret);
51+
req_buf.clear();
52+
}
53+
}
54+
}
55+
else {
56+
std::string req_buf, req_line;
57+
while(1) {
58+
getline(in, req_line);
59+
if(!in)
60+
break;
61+
req_buf += req_line + "\r\n";
62+
if(req_line.empty()) {
63+
const auto ret = ukagaka::protocol_message{shiori(req_buf)};
64+
out << to_ansi_colored_string(ret);
65+
req_buf.clear();
66+
}
5067
}
5168
}
5269
}

0 commit comments

Comments
 (0)