add dosbox shim

This commit is contained in:
Andrew Pamment 2018-05-14 08:36:30 +10:00
parent aa73e420c1
commit e42f274c9b
14 changed files with 264 additions and 51 deletions

View File

@ -8,7 +8,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
${LUA}:
cd ../deps/lua && $(MAKE) -f Makefile freebsd MAKEFLAGS=
@ -51,8 +51,11 @@ magichat: $(JSMN)
mgpost: $(JAMLIB)
cd ../utils/mgpost && $(MAKE)
fileapprove: $(CDK)
cd ../utils/fileapprove && $(MAKE)
filecenter: $(CDK)
cd ../utils/filecenter && $(MAKE)
dosbox_shim:
cd ../utils/dosbox_shim && $(MAKE)
magiftpd:
cd ../utils/magiftpd && $(MAKE)
@ -74,6 +77,7 @@ clean:
cd ../utils/mgpost && $(MAKE) clean
cd ../utils/magichat && $(MAKE) clean
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
cd ../utils/fileapprove && $(MAKE) clean
cd ../utils/filecenter && $(MAKE) clean
cd ../utils/magiftpd && $(MAKE) clean
cd ../utils/reset_pass && $(MAKE) clean
cd ../utils/dosbox_shim && $(MAKE) clean

View File

@ -10,7 +10,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
${LUA}:
cd ../deps/lua && $(MAKE) -f Makefile freebsd MAKEFLAGS=
@ -56,8 +56,11 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd ../utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd ../utils/fileapprove && $(MAKE)
filecenter: $(CDK)
cd ../utils/filecenter && $(MAKE)
dosbox_shim:
cd ../utils/dosbox_shim && $(MAKE)
magiftpd:
cd ../utils/magiftpd && $(MAKE)
@ -80,6 +83,7 @@ clean:
cd ../utils/mgpost && $(MAKE) clean
cd ../utils/magichat && $(MAKE) clean
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
cd ../utils/fileapprove && $(MAKE) clean
cd ../utils/filecenter && $(MAKE) clean
cd ../utils/magiftpd && $(MAKE) clean
cd ../utils/reset_pass && $(MAKE) clean
cd ../utils/dosbox_shim && $(MAKE) clean

View File

@ -8,7 +8,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
${LUA}:
cd ../deps/lua && $(MAKE) -f Makefile linux MAKEFLAGS=
@ -52,8 +52,11 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd ../utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd ../utils/fileapprove && $(MAKE)
filecenter: $(CDK)
cd ../utils/filecenter && $(MAKE)
dosbox_shim:
cd ../utils/dosbox_shim && $(MAKE)
magiftpd:
cd ../utils/magiftpd && $(MAKE)
@ -75,6 +78,7 @@ clean:
cd ../utils/mgpost && $(MAKE) clean
cd ../utils/magichat && $(MAKE) clean
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
cd ../utils/fileapprove && $(MAKE) clean
cd ../utils/filecenter && $(MAKE) clean
cd ../utils/magiftpd && $(MAKE) clean
cd ../utils/reset_pass && $(MAKE) clean
cd ../utils/dosbox_shim && $(MAKE) clean

View File

@ -10,7 +10,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
${LUA}:
cd ../deps/lua && $(MAKE) -f Makefile linux MAKEFLAGS=
@ -56,8 +56,11 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd ../utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd ../utils/fileapprove && $(MAKE)
filecenter: $(CDK)
cd ../utils/filecenter && $(MAKE)
dosbox_shim:
cd ../utils/dosbox_shim && $(MAKE)
magiftpd:
cd ../utils/magiftpd && $(MAKE)
@ -80,6 +83,7 @@ clean:
cd ../utils/mgpost && $(MAKE) clean
cd ../utils/magichat && $(MAKE) clean
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
cd ../utils/fileapprove && $(MAKE) clean
cd ../utils/filecenter && $(MAKE) clean
cd ../utils/magiftpd && $(MAKE) clean
cd ../utils/reset_pass && $(MAKE) clean
cd ../utils/dosbox_shim && $(MAKE) clean

View File

@ -8,7 +8,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
${LUA}:
cd ../deps/lua && $(MAKE) -f Makefile bsd MAKEFLAGS=
@ -51,8 +51,11 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd ../utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd ../utils/fileapprove && $(MAKE)
filecenter: $(CDK)
cd ../utils/filecenter && $(MAKE)
dosbox_shim:
cd ../utils/dosbox_shim && $(MAKE)
magiftpd:
cd ../utils/magiftpd && $(MAKE)
@ -74,6 +77,7 @@ clean:
cd ../utils/mgpost && $(MAKE) clean
cd ../utils/magichat && $(MAKE) clean
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
cd ../utils/fileapprove && $(MAKE) clean
cd ../utils/filecenter && $(MAKE) clean
cd ../utils/magiftpd && $(MAKE) clean
cd ../utils/reset_pass && $(MAKE) clean
cd ../utils/dosbox_shim && $(MAKE) clean

View File

@ -10,7 +10,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
${LUA}:
cd ../deps/lua && $(MAKE) -f Makefile bsd MAKEFLAGS=
@ -56,8 +56,11 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd ../utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd ../utils/fileapprove && $(MAKE)
filecenter: $(CDK)
cd ../utils/filecenter && $(MAKE)
dosbox_shim:
cd ../utils/dosbox_shim && $(MAKE)
magiftpd:
cd ../utils/magiftpd && $(MAKE)
@ -80,6 +83,7 @@ clean:
cd ../utils/mgpost && $(MAKE) clean
cd ../utils/magichat && $(MAKE) clean
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
cd ../utils/fileapprove && $(MAKE) clean
cd ../utils/filecenter && $(MAKE) clean
cd ../utils/magiftpd && $(MAKE) clean
cd ../utils/reset_pass && $(MAKE) clean
cd ../utils/dosbox_shim && $(MAKE) clean

View File

@ -8,7 +8,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
${LUA}:
cd ../deps/lua && $(MAKE) -f Makefile bsd MAKEFLAGS=
@ -51,8 +51,11 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd ../utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd ../utils/fileapprove && $(MAKE)
filecenter: $(CDK)
cd ../utils/filecenter && $(MAKE)
dosbox_shim:
cd ../utils/dosbox_shim && $(MAKE)
magiftpd:
cd ../utils/magiftpd && $(MAKE)
@ -74,7 +77,7 @@ clean:
cd ../utils/mgpost && $(MAKE) clean
cd ../utils/magichat && $(MAKE) clean
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
cd ../utils/fileapprove && $(MAKE) clean
cd ../utils/filecenter && $(MAKE) clean
cd ../utils/magiftpd && $(MAKE) clean
cd ../utils/reset_pass && $(MAKE) clean
cd ../utils/dosbox_shim && $(MAKE) clean

View File

@ -10,7 +10,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
${LUA}:
cd ../deps/lua && $(MAKE) -f Makefile bsd MAKEFLAGS=
@ -56,8 +56,11 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd ../utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd ../utils/fileapprove && $(MAKE)
filecenter: $(CDK)
cd ../utils/filecenter && $(MAKE)
dosbox_shim:
cd ../utils/dosbox_shim && $(MAKE)
magiftpd:
cd ../utils/magiftpd && $(MAKE)
@ -80,7 +83,7 @@ clean:
cd ../utils/mgpost && $(MAKE) clean
cd ../utils/magichat && $(MAKE) clean
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
cd ../utils/fileapprove && $(MAKE) clean
cd ../utils/filecenter && $(MAKE) clean
cd ../utils/magiftpd && $(MAKE) clean
cd ../utils/reset_pass && $(MAKE) clean
cd ../utils/dosbox_shim && $(MAKE) clean

View File

@ -10,7 +10,7 @@ CDK = ../deps/cdk-5-20161210/libcdk.a
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
${LUA}:
cd ../deps/lua && $(MAKE) -f Makefile macosx MAKEFLAGS=
@ -52,8 +52,11 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd ../utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd ../utils/fileapprove && $(MAKE)
filecenter: $(CDK)
cd ../utils/filecenter && $(MAKE)
dosbox_shim:
cd ../utils/dosbox_shim && $(MAKE)
magiftpd:
cd ../utils/magiftpd && $(MAKE)
@ -75,6 +78,7 @@ clean:
cd ../utils/mgpost && $(MAKE) clean
cd ../utils/magichat && $(MAKE) clean
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
cd ../utils/fileapprove && $(MAKE) clean
cd ../utils/filecenter && $(MAKE) clean
cd ../utils/magiftpd && $(MAKE) clean
cd ../utils/reset_pass && $(MAKE) clean
cd ../utils/dosbox_shim && $(MAKE) clean

View File

@ -10,7 +10,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
${LUA}:
cd ../deps/lua && $(MAKE) -f Makefile macosx MAKEFLAGS=
@ -56,8 +56,11 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd ../utils/magichat && $(MAKE)
fileapprove: $(CDK)
cd ../utils/fileapprove && $(MAKE)
filecenter: $(CDK)
cd ../utils/filecenter && $(MAKE)
dosbox_shim:
cd ../utils/dosbox_shim && $(MAKE)
magiftpd:
cd ../utils/magiftpd && $(MAKE)
@ -79,6 +82,7 @@ clean:
cd ../utils/mgpost && $(MAKE) clean
cd ../utils/magichat && $(MAKE) clean
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
cd ../utils/fileapprove && $(MAKE) clean
cd ../utils/filecenter && $(MAKE) clean
cd ../utils/magiftpd && $(MAKE) clean
cd ../utils/reset_pass && $(MAKE) clean
cd ../utils/dosbox_shim && $(MAKE) clean

View File

@ -8,7 +8,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
${LUA}:
cd ../deps/lua && $(MAKE) -f Makefile solaris MAKEFLAGS=
@ -52,8 +52,11 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd ../utils/magichat && $(MAKE) -f Makefile.sunos
fileapprove: $(CDK)
cd ../utils/fileapprove && $(MAKE)
filecenter: $(CDK)
cd ../utils/filecenter && $(MAKE)
dosbox_shim:
cd ../utils/dosbox_shim && $(MAKE)
magiftpd:
cd ../utils/magiftpd && $(MAKE)
@ -75,6 +78,7 @@ clean:
cd ../utils/mgpost && $(MAKE) clean
cd ../utils/magichat && $(MAKE) clean
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
cd ../utils/fileapprove && $(MAKE) clean
cd ../utils/filecenter && $(MAKE) clean
cd ../utils/magiftpd && $(MAKE) clean
cd ../utils/reset_pass && $(MAKE) clean
cd ../utils/dosbox_shim && $(MAKE) clean

View File

@ -10,7 +10,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
all: magicka magimail magiedit ticproc mgpost magichat filecenter magiftpd reset_pass
${LUA}:
cd ../deps/lua && $(MAKE) -f Makefile solaris MAKEFLAGS=
@ -56,8 +56,11 @@ mgpost: $(JAMLIB)
magichat: $(JSMN)
cd ../utils/magichat && $(MAKE) -f Makefile.sunos
fileapprove: $(CDK)
cd ../utils/fileapprove && $(MAKE)
filecenter: $(CDK)
cd ../utils/filecenter && $(MAKE)
dosbox_shim:
cd ../utils/dosbox_shim && $(MAKE)
magiftpd:
cd ../utils/magiftpd && $(MAKE)
@ -80,6 +83,7 @@ clean:
cd ../utils/mgpost && $(MAKE) clean
cd ../utils/magichat && $(MAKE) clean
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
cd ../utils/fileapprove && $(MAKE) clean
cd ../utils/filecenter && $(MAKE) clean
cd ../utils/magiftpd && $(MAKE) clean
cd ../utils/reset_pass && $(MAKE) clean
cd ../utils/dosbox_shim && $(MAKE) clean

View File

@ -0,0 +1,51 @@
OS := $(shell uname -s)
ifeq ($(OS), FreeBSD)
CC=cc
CFLAGS=-I/usr/local/include
LDFLAGS=-L/usr/local/lib
endif
ifeq ($(OS), DragonFly)
CC=cc
CFLAGS=-I/usr/local/include -I/usr/local/include/ncurses
LDFLAGS=-L/usr/local/lib
endif
ifeq ($(OS), NetBSD)
CC=cc
CFLAGS=-I/usr/pkg/include
LDFLAGS=-R/usr/pkg/lib -L/usr/pkg/lib
endif
ifeq ($(OS), OpenBSD)
CC=cc
CFLAGS=-I/usr/local/include
LDFLAGS=-L/usr/local/lib
endif
ifeq ($(OS), Linux)
CC=gcc
CFLAGS=
LDFLAGS=
endif
ifeq ($(OS), Darwin)
CC=cc
CFLAGS=
LDFLAGS=
endif
ifeq ($(OS), SunOS)
CC=gcc
CFLAGS=
LDFLAGS=
endif
DEPS = main.c
OBJ = main.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
shim: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
.PHONY: clean
clean:
rm -f $(OBJ) shim

116
utils/dosbox_shim/main.c Normal file
View File

@ -0,0 +1,116 @@
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#if defined(__OpenBSD__)
# include <sys/select.h>
#endif
int main(int argc, char **argv) {
int port;
int node;
char *script;
pid_t pid;
int server_socket;
int on = 1;
struct sockaddr_in server, client;
int client_fd;
int c;
fd_set master, read_fds;
int len;
char inbuf[256];
int i;
char *arguments[4];
if (argc < 4) {
fprintf(stderr, "Usage ./dosbox_shim [port] [node] [script]\n");
exit(-1);
}
port = atoi(argv[1]);
node = atoi(argv[2]);
script = strdup(argv[3]);
pid = fork();
if (pid < 0) {
fprintf(stderr, "Error forking!\n");
exit(-1);
} else if (pid == 0) {
arguments[0] = strdup(script);
sprintf(inbuf, "%d", port);
arguments[1] = strdup(inbuf);
sprintf(inbuf, "%d", node);
arguments[2] = strdup(inbuf);
arguments[3] = NULL;
execvp(script, arguments);
} else {
server_socket = socket(AF_INET, SOCK_STREAM, 0);
if (server_socket == -1) {
fprintf(stderr, "Couldn't create socket.\n");
exit(-1);
}
if (setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) {
fprintf(stderr, "setsockopt(SO_REUSEADDR) failed");
exit(1);
}
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
server.sin_port = htons(port);
c = sizeof(struct sockaddr_in);
if (bind(server_socket, (struct sockaddr *)&server, sizeof(server)) < 0) {
perror("Bind Failed, Error\n");
exit(-1);
}
listen(server_socket, 1);
client_fd = accept(server_socket, (struct sockaddr *)&client, (socklen_t *)&c);
if (client_fd == -1) {
perror("accept");
exit(-1);
}
FD_ZERO(&master);
FD_SET(STDIN_FILENO, &master);
FD_SET(client_fd, &master);
while(1) {
read_fds = master;
if (select(client_fd + 1, &read_fds, NULL, NULL, NULL) == -1) {
perror("select");
exit(-1);
}
if (FD_ISSET(STDIN_FILENO, &read_fds)) {
len = read(STDIN_FILENO, inbuf, 256);
for (i=0;i<len;i++) {
write(client_fd, &inbuf[i], 1);
}
}
if (FD_ISSET(client_fd, &read_fds)) {
len = read(client_fd, inbuf, 256);
if (len == 0) {
close(client_fd);
exit(0);
}
for (i=0;i<len;i++) {
write(STDOUT_FILENO, &inbuf[i], 1);
}
}
}
}
}