Skip to content
Snippets Groups Projects
Commit 993d8b7c authored by Fredrik Hübinette (Hubbe)'s avatar Fredrik Hübinette (Hubbe)
Browse files

fixes for running under wine

Rev: NT/tools/lib.pike:1.6
Rev: NT/tools/rntcc:1.20
Rev: NT/tools/sprshd:1.13
parent a31ba359
No related branches found
No related tags found
No related merge requests found
...@@ -37,10 +37,14 @@ int silent_do_cmd(string *cmd, mixed|void filter, int|void silent) ...@@ -37,10 +37,14 @@ int silent_do_cmd(string *cmd, mixed|void filter, int|void silent)
#endif #endif
{ {
object o=f->pipe(Stdio.PROP_BIDIRECTIONAL | Stdio.PROP_IPC); object o=f->pipe(Stdio.PROP_BIDIRECTIONAL | Stdio.PROP_IPC);
object proc=Process.create_process(({"wine", cmd=({"wine",
"-debugmsg","fixme-all", "-winver","win95",
cmd*" "}), "-debugmsg","fixme-all",
(["stdout":o])); "-debugmsg","trace+all",
"-debugmsg","+relay",
cmd*" "});
// werror("WINE %O\n",cmd);
object proc=Process.create_process(cmd,(["stdout":o]));
destruct(o); destruct(o);
while(1) while(1)
{ {
......
...@@ -105,7 +105,7 @@ int main(int argc, string *argv) ...@@ -105,7 +105,7 @@ int main(int argc, string *argv)
({"link",Getopt.HAS_ARG, ({"-l"}) }), ({"link",Getopt.HAS_ARG, ({"-l"}) }),
({"share",Getopt.MAY_HAVE_ARG, ({"-s"}) }), ({"share",Getopt.MAY_HAVE_ARG, ({"-s"}) }),
({"ignore",Getopt.MAY_HAVE_ARG, ({"-t"}) }), ({"ignore",Getopt.MAY_HAVE_ARG, ({"-t"}) }),
({"ignore",Getopt.HAS_ARG, ({"-R","-L"}) }), ({"ignore",Getopt.HAS_ARG, ({"-R","-L","-r"}) }),
({"warn",Getopt.MAY_HAVE_ARG, ({"-W"}) }), ({"warn",Getopt.MAY_HAVE_ARG, ({"-W"}) }),
({"define",Getopt.HAS_ARG, ({"-D"}) }), ({"define",Getopt.HAS_ARG, ({"-D"}) }),
({"undefine",Getopt.HAS_ARG, ({"-U"})}), ({"undefine",Getopt.HAS_ARG, ({"-U"})}),
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
inherit Stdio.Port; inherit Stdio.Port;
#if !constant(Stdio.PROP_IPC)
#define NO_IPC
#endif
// Bugfix for some older versions of Pike.. // Bugfix for some older versions of Pike..
string combine_path(string s, string ... rest) string combine_path(string s, string ... rest)
{ {
...@@ -69,6 +73,16 @@ void monitor(object(Stdio.File) io, object proc) ...@@ -69,6 +73,16 @@ void monitor(object(Stdio.File) io, object proc)
} }
} }
#ifdef WINE
void my_proxy(Stdio.File from, Stdio.File to)
{
while(string s=from->read(128,1))
if(to->write(s)!=strlen(s))
return;
}
#endif
void handle_incoming_connection(object(Stdio.File) io) void handle_incoming_connection(object(Stdio.File) io)
{ {
object p; object p;
...@@ -81,10 +95,10 @@ void handle_incoming_connection(object(Stdio.File) io) ...@@ -81,10 +95,10 @@ void handle_incoming_connection(object(Stdio.File) io)
} }
object pi=Stdio.File(); object pi=Stdio.File();
#if constant(Stdio.PROP_IPC) #ifdef NO_IPC
object p2=pi->pipe(Stdio.PROP_IPC);
#else
object p2=pi->pipe(); object p2=pi->pipe();
#else
object p2=pi->pipe(Stdio.PROP_IPC);
#endif #endif
string dir=cmd[0]; string dir=cmd[0];
cmd=cmd[1..]; cmd=cmd[1..];
...@@ -144,19 +158,35 @@ void handle_incoming_connection(object(Stdio.File) io) ...@@ -144,19 +158,35 @@ void handle_incoming_connection(object(Stdio.File) io)
} }
default: default:
#ifdef WINE
{
werror("Proxying.....\n");
object p3=Stdio.File();
#ifdef NO_IPC
object p4=p3->pipe();
#else
object p4=p3->pipe(Stdio.PROP_IPC);
#endif
thread_create(my_proxy,io,p4);
io=p3;
}
#endif
mixed err=catch { mixed err=catch {
p=Process.create_process(cmd, p=Process.create_process(cmd,
([ ([
#ifndef WINE
"stdin":io, "stdin":io,
"stdout":p2, "stdout":p2,
"stderr":p2, "stderr":p2,
#endif
"cwd":dir, "cwd":dir,
])); ]));
}; };
destruct(p2); destruct(p2);
if(!err) if(!err)
{ {
#if !constant(Stdio.PROP_IPC) #ifdef NO_IPC
thread_create(monitor,p2,p); thread_create(monitor,p2,p);
#endif #endif
while(1) while(1)
...@@ -169,6 +199,7 @@ void handle_incoming_connection(object(Stdio.File) io) ...@@ -169,6 +199,7 @@ void handle_incoming_connection(object(Stdio.File) io)
io->write(sprintf("%4c",0)); io->write(sprintf("%4c",0));
io->write(sprintf("%4c",p->wait())); io->write(sprintf("%4c",p->wait()));
}else{ }else{
werror(master()->describe_backtrace(err));
destruct(p2); destruct(p2);
io->write(sprintf("%4c",0)); io->write(sprintf("%4c",0));
io->write(sprintf("%4c",69)); io->write(sprintf("%4c",69));
...@@ -178,8 +209,30 @@ void handle_incoming_connection(object(Stdio.File) io) ...@@ -178,8 +209,30 @@ void handle_incoming_connection(object(Stdio.File) io)
destruct(io); destruct(io);
} }
void handle_connections(string *hosts)
{
while(1)
{
if(object io=accept())
{
sscanf(io->query_address(),"%s ",string ip);
if(search(hosts, ip)==-1)
{
destruct(io);
continue;
}
thread_create(handle_incoming_connection,io);
}else{
werror("Accept failed "+errno()+"\n");
}
}
}
int main(int argc, string *argv) int main(int argc, string *argv)
{ {
#ifdef WINE
werror("Running in WINE mode.\n");
#endif
if(argc<2) if(argc<2)
{ {
werror("Usage: sprshd <port> <hosts to accept connections from>\n"); werror("Usage: sprshd <port> <hosts to accept connections from>\n");
...@@ -209,19 +262,13 @@ int main(int argc, string *argv) ...@@ -209,19 +262,13 @@ int main(int argc, string *argv)
} }
write("Ready ("+version()+").\n"); write("Ready ("+version()+").\n");
while(1)
{ #ifdef WINE
if(object io=accept()) thread_create(handle_connections,hosts);
{ werror("main returning...\n");
sscanf(io->query_address(),"%s ",string ip); return -1;
if(search(hosts, ip)==-1) #else
{ handle_connection(hosts);
destruct(io); return 0;
continue; #endif
}
thread_create(handle_incoming_connection,io);
}else{
werror("Accept failed "+errno()+"\n");
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment