Skip to content

Commit

Permalink
fix console readin
Browse files Browse the repository at this point in the history
  • Loading branch information
steve02081504 committed May 21, 2023
1 parent 4b62956 commit b0acbff
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 25 deletions.
2 changes: 2 additions & 0 deletions shioricaller.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<StringPooling>true</StringPooling>
<BuildStlModules>false</BuildStlModules>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down Expand Up @@ -151,6 +152,7 @@
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<StringPooling>true</StringPooling>
<BuildStlModules>false</BuildStlModules>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down
17 changes: 16 additions & 1 deletion shioricaller.vcxproj.user
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerCommandArguments>E:\ssp\ghost\Taromati2\ghost\master\shiori\aya.dll</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerCommandArguments>E:\ssp\ghost\Taromati2\ghost\master\shiori\aya.dll</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommandArguments>E:\ssp\ghost\Taromati2\ghost\master\shiori\aya.dll</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommandArguments>E:\ssp\ghost\Taromati2\ghost\master\shiori\aya.dll</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/_gists.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "my-gists/ukagaka/shiori_loader.cpp"
#include "my-gists/ukagaka/protocol_message.cpp"
#include "my-gists/windows/GenerateDump.cpp"
#include "my-gists/windows/EnableVirtualTerminal.cpp"
#include "my-gists/windows/small_io.cpp"
2 changes: 1 addition & 1 deletion src/my-gists
Submodule my-gists updated 50 files
+2 −0 .gitignore
+35 −4 STL/CutSpace.cpp
+3 −0 STL/CutSpace.hpp
+55 −0 STL/Split.cpp
+10 −0 STL/Split.hpp
+1 −0 STL/string_add_string_view.cpp
+17 −0 STL/string_add_string_view.hpp
+45 −0 STL/to_json_X.cpp
+3 −0 STL/to_json_X.hpp
+1 −0 ansi_color.cpp
+23 −0 ansi_color.hpp
+1 −1 codepage.cpp
+68 −12 codepage.hpp
+92 −38 file/canXfile.cpp
+7 −7 socket.hpp
+5 −5 ukagaka/SFMO.cpp
+2 −2 ukagaka/SSP_Runner.cpp
+9 −9 ukagaka/SSP_Runner.hpp
+2 −2 ukagaka/SSPpath.cpp
+121 −0 ukagaka/from_ghost_path.cpp
+13 −0 ukagaka/from_ghost_path.hpp
+19 −1 ukagaka/ghost_path.cpp
+1 −0 ukagaka/ghost_path.hpp
+2 −2 ukagaka/protocol_message.cpp
+39 −19 ukagaka/protocol_message.hpp
+30 −29 ukagaka/shiori_loader.cpp
+26 −24 ukagaka/shiori_loader.hpp
+26 −22 ukagaka/sstp.hpp
+1 −1 ukagaka/string2HGLOBAL.cpp
+1 −1 ukagaka/string2HGLOBAL.hpp
+1 −0 windows/CharWidthMap.cpp
+121 −0 windows/CharWidthMap.hpp
+3 −3 windows/EXE_Runner.cpp
+7 −7 windows/EXE_Runner.hpp
+7 −4 windows/GenerateDump.cpp
+46 −0 windows/InWindowsTerminal.cpp
+1 −0 windows/InWindowsTerminal.hpp
+19 −0 windows/IsElevated.cpp
+1 −0 windows/IsElevated.hpp
+22 −2 windows/LoadStringFromResource.cpp
+5 −1 windows/LoadStringFromResource.hpp
+64 −9 windows/SetIcon.cpp
+23 −2 windows/SetIcon.h
+4 −3 windows/WaitForXObjectWithMessageLoop.cpp
+1 −1 windows/WaitForXObjectWithMessageLoop.hpp
+2 −2 windows/clipboard.cpp
+534 −191 windows/shell_base.cpp
+248 −6 windows/shell_base.hpp
+1 −0 windows/small_io.cpp
+187 −0 windows/small_io.hpp
61 changes: 39 additions & 22 deletions src/shioricaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,28 @@

#include "my-gists/ukagaka/shiori_loader.hpp"
#include "my-gists/ukagaka/protocol_message.hpp"
#include "my-gists/windows/GenerateDump.hpp"
#include "my-gists/windows/EnableVirtualTerminal.hpp"
#include "my-gists/windows/small_io.hpp"
#include "my-gists/ansi_color.hpp"
#include <iostream>

#include <string>

int wmain(int argc, wchar_t* argv[]){
InstallExceptionFilter();
EnableVirtualTerminal();//for color output

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

auto error_handler = [](Cshiori::Error err) {
std::cerr << RED_OUTPUT("Error: " << to_ansi_colored_string(err)) << std::endl;
auto error_handler = [](Cshiori::Error aerr) {
err << RED_OUTPUT("Error: " << to_ansi_colored_string(aerr)) << endline;
};

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

if(not shiori.All_OK())
return 1;

std::string req_buf,req_line;
while(1) {
std::getline(std::cin, req_line);
if(std::cin.eof())break;
req_buf += req_line + "\r\n";
if(req_line.empty()) {
const auto ret = ukagaka::protocol_message{shiori(req_buf)};
std::cout << to_ansi_colored_string(ret);
req_buf.clear();
if(in.is_console()) {
std::wstring req_buf, req_line;
while(1) {
getline(in, req_line);
if(!in)
break;
req_buf += req_line + L"\r\n";
if(req_line.empty()) {
const auto request = ukagaka::protocol_message{req_buf};
const auto code_cvted_request = std::string(request);
const auto ret = ukagaka::protocol_message{shiori(code_cvted_request)};
out << to_ansi_colored_wstring(ret);
req_buf.clear();
}
}
}
else {
std::string req_buf, req_line;
while(1) {
getline(in, req_line);
if(!in)
break;
req_buf += req_line + "\r\n";
if(req_line.empty()) {
const auto ret = ukagaka::protocol_message{shiori(req_buf)};
out << to_ansi_colored_string(ret);
req_buf.clear();
}
}
}
}

0 comments on commit b0acbff

Please sign in to comment.