This commit is contained in:
Andrew Pamment 2021-03-12 19:14:22 +10:00
parent 29a19692fe
commit 18a23222a9
5 changed files with 24 additions and 10 deletions

View File

@ -2,10 +2,11 @@
#include <stdio.h> #include <stdio.h>
#if defined(_MSC_VER) || defined(WIN32) #if defined(_MSC_VER) || defined(WIN32)
#include <winsock2.h> #include <winsock2.h>
#define STDIN_FILENO 1
#else #else
#include <sys/socket.h> #include <sys/socket.h>
#endif
#include <unistd.h> #include <unistd.h>
#endif
#include <time.h> #include <time.h>
#include <string.h> #include <string.h>
#include "MagiDoor.h" #include "MagiDoor.h"
@ -17,7 +18,7 @@ extern time_t mdtimeremaining;
char md_getc() { char md_getc() {
char c; char c;
ssize_t ret; int ret;
int stage = 0; int stage = 0;
@ -43,9 +44,16 @@ char md_getc() {
md_printf("\r\nOut of time!\r\n"); md_printf("\r\nOut of time!\r\n");
md_exit(0); md_exit(0);
} }
#if defined(_MSC_VER)
Sleep(1);
#else
usleep(100); usleep(100);
#endif
continue; continue;
} }
else if (ret < 0) {
md_exit(0);
}
if (mdcontrol.socket != -1) { if (mdcontrol.socket != -1) {
if ((unsigned char)c == IAC && stage == 0) { if ((unsigned char)c == IAC && stage == 0) {

View File

@ -1,13 +1,14 @@
#include <stdio.h> #include <stdio.h>
#if defined(WIN32) || defined(_MSC_VER) #if defined(WIN32) || defined(_MSC_VER)
#include <winsock2.h> #include <winsock2.h>
#define strcasecmp stricmp
#else #else
#include <termios.h> #include <termios.h>
#include <signal.h> #include <signal.h>
#include <unistd.h>
#endif #endif
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <time.h> #include <time.h>
#include "MagiDoor.h" #include "MagiDoor.h"

View File

@ -1,12 +1,15 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#if defined(_MSC_VER) || defined(WIN32) #if defined(_MSC_VER) || defined(WIN32)
#include <winsock2.h> #include <winsock2.h>
#include "MD_AnsiCons.h" #include "MD_AnsiCons.h"
#define STDOUT_FILENO 0
#else #else
#include <sys/socket.h> #include <sys/socket.h>
#include <unistd.h>
#endif #endif
#include "MagiDoor.h" #include "MagiDoor.h"

View File

@ -23,6 +23,8 @@ typedef struct MDDoorControl {
extern MDDoorControl_t mdcontrol; extern MDDoorControl_t mdcontrol;
extern void md_init(const char* dropfile, int socket); extern void md_init(const char* dropfile, int socket);
extern void md_exit(int exitcode); extern void md_exit(int exitcode);
extern void md_putchar(char c); extern void md_putchar(char c);