|
@@ -32,11 +32,13 @@ static bool hangup = false;
|
|
|
|
|
|
void sig_handler(int signal) {
|
|
|
hangup = true;
|
|
|
+
|
|
|
ofstream sigf;
|
|
|
sigf.open("signal.log", std::ofstream::out | std::ofstream::app);
|
|
|
|
|
|
sigf << "SNAP! GOT: " << signal << std::endl;
|
|
|
sigf.close();
|
|
|
+ */
|
|
|
|
|
|
}
|
|
|
|
|
@@ -84,6 +86,7 @@ void cp437toUnicode(const char *input, std::string &out) {
|
|
|
}
|
|
|
|
|
|
bool unicode = false;
|
|
|
+bool debug_capture = false;
|
|
|
|
|
|
|
|
|
* Construct a new Door object using the commandline parameters
|
|
@@ -182,16 +185,11 @@ Door::Door(std::string dname, int argc, char *argv[])
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
std::string logFileName = dname + ".log";
|
|
|
logf.open(logFileName.c_str(), std::ofstream::out | std::ofstream::app);
|
|
|
|
|
|
log("Door init");
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
init();
|
|
|
|
|
|
|
|
@@ -200,11 +198,6 @@ Door::Door(std::string dname, int argc, char *argv[])
|
|
|
}
|
|
|
|
|
|
Door::~Door() {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
tcsetattr(STDIN_FILENO, TCOFLUSH, &tio_default);
|
|
@@ -269,7 +262,7 @@ void Door::detect_unicode_and_screen(void) {
|
|
|
*this << "\377\375\042\377\373\001";
|
|
|
}
|
|
|
|
|
|
- *this << "\x1b[0;30;40m;\x1b[2J\x1b[H";
|
|
|
+ *this << "\x1b[0;30;40m\x1b[2J\x1b[H";
|
|
|
*this << "\u2615"
|
|
|
<< "\x1b[6n";
|
|
|
*this << "\x1b[999C\x1b[999B\x1b[6n";
|
|
@@ -303,8 +296,16 @@ void Door::detect_unicode_and_screen(void) {
|
|
|
logf << std::endl;
|
|
|
logf << "BUFFER [" << (char *)buffer << "]" << std::endl;
|
|
|
*/
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- if (strstr(buffer, "1;2R") != nullptr) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if ((strstr(buffer, "1;2R") != nullptr) or
|
|
|
+ (strstr(buffer, "1;3R") != nullptr)) {
|
|
|
unicode = true;
|
|
|
log("unicode enabled \u2615");
|
|
|
}
|
|
@@ -434,7 +435,10 @@ signed int Door::getch(void) {
|
|
|
char key;
|
|
|
|
|
|
if (door::hangup)
|
|
|
- return -1;
|
|
|
+ return -2;
|
|
|
+
|
|
|
+ if (time_left < 2)
|
|
|
+ return -3;
|
|
|
|
|
|
while (select_ret == -1) {
|
|
|
FD_ZERO(&socket_set);
|
|
@@ -686,16 +690,20 @@ signed int Door::sleep_key(int secs) {
|
|
|
* @return std::streamsize
|
|
|
*/
|
|
|
std::streamsize Door::xsputn(const char *s, std::streamsize n) {
|
|
|
- static std::string buffer;
|
|
|
- buffer.append(s, n);
|
|
|
-
|
|
|
- std::cout << buffer;
|
|
|
- std::cout.flush();
|
|
|
-
|
|
|
-
|
|
|
- if (track)
|
|
|
- cx += n;
|
|
|
- buffer.clear();
|
|
|
+ if (debug_capture) {
|
|
|
+ debug_buffer.append(s, n);
|
|
|
+ } else {
|
|
|
+ static std::string buffer;
|
|
|
+ buffer.append(s, n);
|
|
|
+
|
|
|
+ std::cout << buffer;
|
|
|
+ std::cout.flush();
|
|
|
+
|
|
|
+
|
|
|
+ if (track)
|
|
|
+ cx += n;
|
|
|
+ buffer.clear();
|
|
|
+ }
|
|
|
return n;
|
|
|
}
|
|
|
|
|
@@ -716,8 +724,12 @@ int Door::overflow(char c) {
|
|
|
|
|
|
|
|
|
|
|
|
- std::cout << c;
|
|
|
- std::cout.flush();
|
|
|
+ if (debug_capture) {
|
|
|
+ debug_buffer.append(1, c);
|
|
|
+ } else {
|
|
|
+ std::cout << c;
|
|
|
+ std::cout.flush();
|
|
|
+ }
|
|
|
if (track)
|
|
|
cx++;
|
|
|
|