[Freeciv-Dev] bugfixen civserver_readline
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
wrapper was buggy (is still ???)
empty command confused (read: hanged) it
here's better one :
*** START ***
#!/usr/bin/perl -w
# Wraper over civserver to use readline facilites
# Copyright (c) 2000 Tomasz Węgrzanowski <maniek@xxxxxxxx>
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# On Debian GNU/Linux systems, the complete text of the GNU General
# Public License can be found in `/usr/share/common-licenses/GPL'.
use Term::ReadLine;
use IPC::Open3;
pipe CS_W,CS_E;
open3 \*CS_W,\*CS_E,\*CS_E,"civserver @ARGV >&2";
$SIG{'INT'} = \&finish;
my $term = new Term::ReadLine 'Freeciv server';
my $prompt = 'freeciv> ';
while (1) {
$read = sysread (CS_E,$ans,256);
exit unless ($read);
READMORE:
if ($ans =~ /\n>\s$/ ) {
$ans =~ s/>\s$//;
print $ans;
print CS_W ($term->readline ($prompt)),"\n";
}
else {
if ($ans eq '> ') {
print CS_W ($term->readline ($prompt)),"\n";
next;
}
if ($ans =~ /\n>?$/ ) {
my $readcont = sysread (CS_E,$anscont,256);
exit unless ($readcont);
$ans .= $anscont;
goto READMORE;
}
print $ans;
}
}
sub finish {
print "Exiting at user's request\n";
print CS_W "quit\n";
close CS_W;
exit;
}
**** END ****
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] bugfixen civserver_readline,
Tomasz Wegrzanowski <=
|
|