Setting up a FICS-like server
Moderators: hgm, Rebel, chrisw
-
- Posts: 27816
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Setting up a FICS-like server
Someone asked me how to set up a FICS-like server, like I have done for the Variant Server on which we have the monthly blitz tourneys. It seemed a good idea todo this in a public place, where people that attempt it could also ask questions and report trouble.
You might want to start by creating a new user "chessd" in your password file, with as home directory /usr/local/chessd, and then log in as this user before you start to install (so that all files you make will have the correct owner). Although it is perfectly possible to install and run the server under your own Linux account.
I use a (slightly modified and debugged) version of the Lasker-2.2.3 code, which runs under Linux. The source code of this can be obtained from my repository at http://hgm.nubati.net/cgi-bin/gitweb.cgi , proect "capablanca.git". After clicking the proect, click the "snapshot" of the latest (= upper most) commit to download a tar ball.
After unpacking the tar ball, you should have a file README, which describes how you have to proceed. You have to go to the "src" directory, and type
./configure--prefix=/usr/local
make
sudo make install
This will install the server in the directory /usr/local/chessd.
Assuming you are in the /usr/local/chessd directory, you can then start the server by the command
bin/chessd -f -p 5000
This will start the server, which will then run as a background process, but will continuously spew output to the console window you started it from, so that it is not advisableto use that for anything else. So open a new terminal window, and use the command
telnet localhost 5000
to connect to the server. You should get the ICS login screen, and you can login as guest using the name "admin" (and type <Enter> or password). This allows you to make an administrator account with "addplayer". (Use "ahelp xxx" to get info on ho to use the administrator command xxx.) You will be told the password, and then should logout, and again login using this password.
That is enough for a first start; first let's see if you can get to thispoint before proceeding.
You might want to start by creating a new user "chessd" in your password file, with as home directory /usr/local/chessd, and then log in as this user before you start to install (so that all files you make will have the correct owner). Although it is perfectly possible to install and run the server under your own Linux account.
I use a (slightly modified and debugged) version of the Lasker-2.2.3 code, which runs under Linux. The source code of this can be obtained from my repository at http://hgm.nubati.net/cgi-bin/gitweb.cgi , proect "capablanca.git". After clicking the proect, click the "snapshot" of the latest (= upper most) commit to download a tar ball.
After unpacking the tar ball, you should have a file README, which describes how you have to proceed. You have to go to the "src" directory, and type
./configure--prefix=/usr/local
make
sudo make install
This will install the server in the directory /usr/local/chessd.
Assuming you are in the /usr/local/chessd directory, you can then start the server by the command
bin/chessd -f -p 5000
This will start the server, which will then run as a background process, but will continuously spew output to the console window you started it from, so that it is not advisableto use that for anything else. So open a new terminal window, and use the command
telnet localhost 5000
to connect to the server. You should get the ICS login screen, and you can login as guest using the name "admin" (and type <Enter> or password). This allows you to make an administrator account with "addplayer". (Use "ahelp xxx" to get info on ho to use the administrator command xxx.) You will be told the password, and then should logout, and again login using this password.
That is enough for a first start; first let's see if you can get to thispoint before proceeding.
-
- Posts: 40
- Joined: Fri Mar 05, 2010 2:22 pm
Re: Setting up a FICS-like server
But i have error when i type makehgm wrote: ./configure --prefix=/usr/local
don't forget space
Code: Select all
chessd@sd-21847:~/src$ make
parsers/genstruct.pl -o parsers/parse_info.h gcc -E -fPIC -Wall -g -O2 -DTDB_STANDALONE -I. -I./tdb includes.h
Can't use string ("3") as an ARRAY ref while "strict refs" in use at parsers/genstruct.pl line 181.
Parsing enums: netstatusmake: *** [parsers/parse_info.h] Erreur 9
-
- Posts: 40
- Joined: Fri Mar 05, 2010 2:22 pm
Re: Setting up a FICS-like server
Now i have this error when i make
Code: Select all
chessd@sd-21847:~/src$ make
gcc -c -fPIC -Wall -g -O2 -DTDB_STANDALONE -I. -I./tdb -o parsers/parser.o parsers/parser.c
parsers/parser.c:28: error: expected expression before ‘void’
make: *** [parsers/parser.o] Erreur 1
-
- Posts: 40
- Joined: Fri Mar 05, 2010 2:22 pm
Re: Setting up a FICS-like server
is it correct this file parser.h ?
Code: Select all
/* This is an automatically generated file - DO NOT EDIT! */
static const struct enum_struct einfo_netstatus[] = {
-
- Posts: 27816
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Setting up a FICS-like server
Hmm, that is a severe setback. I had a similar (or even the same) error when I tried to make on Ubuntu 9.04, preventing me to upgrade. On Ubuntu 8.04 it worked without any errors. (Lots of warnings, though.)Denzwell wrote:But i have error when i type make
Code: Select all
chessd@sd-21847:~/src$ make parsers/genstruct.pl -o parsers/parse_info.h gcc -E -fPIC -Wall -g -O2 -DTDB_STANDALONE -I. -I./tdb includes.h Can't use string ("3") as an ARRAY ref while "strict refs" in use at parsers/genstruct.pl line 181. Parsing enums: netstatusmake: *** [parsers/parse_info.h] Erreur 9
genstruct.pl is a Perl script, not? I know nothing of Perl.
Code: Select all
1 #!/usr/bin/perl -w
2 # a simple system for generating C parse info
3 # this can be used to write generic C structer load/save routines
4 # Copyright 2002 Andrew Tridgell <genstruct@tridgell.net>
5 # released under the GNU General Public License v2 or later
6
7 use strict;
8
9 my(%enum_done) = ();
10 my(%struct_done) = ();
11
12 ###################################################
13 # general handler
14 sub handle_general($$$$$$$$)
15 {
16 my($name) = shift;
17 my($ptr_count) = shift;
18 my($size) = shift;
19 my($element) = shift;
20 my($flags) = shift;
21 my($dump_fn) = shift;
22 my($parse_fn) = shift;
23 my($tflags) = shift;
24 my($array_len) = 0;
25 my($dynamic_len) = "NULL";
26
27 # handle arrays, currently treat multidimensional arrays as 1 dimensional
28 while ($element =~ /(.*)\[(.*?)\]$/) {
29 $element = $1;
30 if ($array_len == 0) {
31 $array_len = $2;
32 } else {
33 $array_len = "$2 * $array_len";
34 }
35 }
36
37 if ($flags =~ /_LEN\((\w*?)\)/) {
38 $dynamic_len = ""$1"";
39 }
40
41 if ($flags =~ /_NULLTERM/) {
42 $tflags = "FLAG_NULLTERM";
43 }
44
45 print OFILE "{"$element", $ptr_count, $size, offsetof(struct $name, $element), $array_len, $dynamic_len, $tflags, $dump_fn, $parse_fn},\n";
46 }
47
48
49 ####################################################
50 # parse one element
51 sub parse_one($$$$)
52 {
53 my($name) = shift;
54 my($type) = shift;
55 my($element) = shift;
56 my($flags) = shift;
57 my($ptr_count) = 0;
58 my($size) = "sizeof($type)";
59 my($tflags) = "0";
60
61 # enums get the FLAG_ALWAYS flag
62 if ($type =~ /^enum /) {
63 $tflags = "FLAG_ALWAYS";
64 }
65
66
67 # make the pointer part of the base type
68 while ($element =~ /^\*(.*)/) {
69 $ptr_count++;
70 $element = $1;
71 }
72
73 # convert spaces to _
74 $type =~ s/ /_/g;
75
76 my($dump_fn) = "gen_dump_$type";
77 my($parse_fn) = "gen_parse_$type";
78
79 handle_general($name, $ptr_count, $size, $element, $flags, $dump_fn, $parse_fn, $tflags);
80 }
81
82 ####################################################
83 # parse one element
84 sub parse_element($$$)
85 {
86 my($name) = shift;
87 my($element) = shift;
88 my($flags) = shift;
89 my($type);
90 my($data);
91
92 # pull the base type
93 if ($element =~ /^struct (\S*) (.*)/) {
94 $type = "struct $1";
95 $data = $2;
96 } elsif ($element =~ /^enum (\S*) (.*)/) {
97 $type = "enum $1";
98 $data = $2;
99 } elsif ($element =~ /^unsigned (\S*) (.*)/) {
100 $type = "unsigned $1";
101 $data = $2;
102 } elsif ($element =~ /^const (\S*) (.*)/) {
103 $type = $1;
104 $data = $2;
105 } elsif ($element =~ /^(\S*) (.*)/) {
106 $type = $1;
107 $data = $2;
108 } else {
109 die "Can't parse element '$element'";
110 }
111
112 # handle comma separated lists
113 while ($data =~ /(\S*),[\s]?(.*)/) {
114 parse_one($name, $type, $1, $flags);
115 $data = $2;
116 }
117 parse_one($name, $type, $data, $flags);
118 }
119
120
121 my($first_struct) = 1;
122
123 ####################################################
124 # parse the elements of one structure
125 sub parse_elements($$)
126 {
127 my($name) = shift;
128 my($elements) = shift;
129
130 if ($first_struct) {
131 $first_struct = 0;
132 print "Parsing structs: $name";
133 } else {
134 print ", $name";
135 }
136
137 print OFILE "int gen_dump_struct_$name(struct parse_string *, const char *, unsigned);\n";
138 print OFILE "int gen_parse_struct_$name(char *, const char *);\n";
139
140 print OFILE "static const struct parse_struct pinfo_" . $name . "[] = {\n";
141
142 while ($elements =~ /^.*?([a-z].*?);\s*?(\S*?)\s*?$(.*)/msi) {
143 my($element) = $1;
144 my($flags) = $2;
145 $elements = $3;
146 parse_element($name, $element, $flags);
147 }
148
149 print OFILE "{NULL, 0, 0, 0, 0, NULL, 0, NULL, NULL}};\n";
150
151 print OFILE "
152 int gen_dump_struct_$name(struct parse_string *p, const char *ptr, unsigned indent) {
153 return gen_dump_struct(pinfo_$name, p, ptr, indent);
154 }
155 int gen_parse_struct_$name(char *ptr, const char *str) {
156 return gen_parse_struct(pinfo_$name, ptr, str);
157 }
158
159 ";
160 }
161
162 my($first_enum) = 1;
163
164 ####################################################
165 # parse out the enum declarations
166 sub parse_enum_elements($$)
167 {
168 my($name) = shift;
169 my($elements) = shift;
170
171 if ($first_enum) {
172 $first_enum = 0;
173 print "Parsing enums: $name";
174 } else {
175 print ", $name";
176 }
177
178 print OFILE "static const struct enum_struct einfo_" . $name . "[] = {\n";
179
180 my(@enums) = split(/,/s, $elements);
181 for (my($i)=0; $i <= $#{@enums}; $i++) {
182 my($enum) = $enums[$i];
183 if ($enum =~ /\s*(\w*)/) {
184 my($e) = $1;
185 print OFILE "{"$e", $e},\n";
186 }
187 }
188
189 print OFILE "{NULL, 0}};\n";
190
191 print OFILE "
192 int gen_dump_enum_$name(struct parse_string *p, const char *ptr, unsigned indent) {
193 return gen_dump_enum(einfo_$name, p, ptr, indent);
194 }
195
196 int gen_parse_enum_$name(char *ptr, const char *str) {
197 return gen_parse_enum(einfo_$name, ptr, str);
198 }
199
200 ";
201 }
202
203 ####################################################
204 # parse out the enum declarations
205 sub parse_enums($)
206 {
207 my($data) = shift;
208
209 while ($data =~ /^GENSTRUCT\s+enum\s+(\w*?)\s*{(.*?)}\s*;(.*)/ms) {
210 my($name) = $1;
211 my($elements) = $2;
212 $data = $3;
213
214 if (!defined($enum_done{$name})) {
215 $enum_done{$name} = 1;
216 parse_enum_elements($name, $elements);
217 }
218 }
219
220 if (! $first_enum) {
221 print "\n";
222 }
223 }
224
225 ####################################################
226 # parse all the structures
227 sub parse_structs($)
228 {
229 my($data) = shift;
230
231 # parse into structures
232 while ($data =~ /^GENSTRUCT\s+struct\s+(\w+?)\s*{\s*(.*?)\s*}\s*;(.*)/ms) {
233 my($name) = $1;
234 my($elements) = $2;
235 $data = $3;
236 if (!defined($struct_done{$name})) {
237 $struct_done{$name} = 1;
238 parse_elements($name, $elements);
239 }
240 }
241
242 if (! $first_struct) {
243 print "\n";
244 } else {
245 print "No GENSTRUCT structures found?\n";
246 }
247 }
248
249
250 ####################################################
251 # parse a header file, generating a dumper structure
252 sub parse_data($)
253 {
254 my($data) = shift;
255
256 # collapse spaces
257 $data =~ s/[\t ]+/ /sg;
258 $data =~ s/\s*\n\s+/\n/sg;
259 # strip debug lines
260 $data =~ s/^\#.*?\n//smg;
261
262 parse_enums($data);
263 parse_structs($data);
264 }
265
266
267 #########################################
268 # display help text
269 sub ShowHelp()
270 {
271 print "
272 generator for C structure dumpers
273 Copyright Andrew Tridgell <genstruct\@tridgell.net>
274
275 Sample usage:
276 genstruct -o output.h gcc -E -O2 -g test.h
277
278 Options:
279 --help this help page
280 -o OUTPUT place output in OUTPUT
281 ";
282 exit(0);
283 }
284
285 ########################################
286 # main program
287 if ($ARGV[0] ne "-o" || $#ARGV < 2) {
288 ShowHelp();
289 }
290
291 shift;
292 my($opt_ofile)=shift;
293
294 open(OFILE, ">$opt_ofile") || die "can't open $opt_ofile";
295
296 print OFILE "/* This is an automatically generated file - DO NOT EDIT! */\n\n";
297
298 parse_data(`@ARGV -DGENSTRUCT=GENSTRUCT`);
299 exit(0);
-
- Posts: 40
- Joined: Fri Mar 05, 2010 2:22 pm
Re: Setting up a FICS-like server
is it correct this file parser_info.h ?
my errors
Code: Select all
/* This is an automatically generated file - DO NOT EDIT! */
static const struct enum_struct einfo_netstatus[] = {
Code: Select all
make
gcc -c -fPIC -Wall -g -O2 -DTDB_STANDALONE -I. -I./tdb -o parsers/parser.o parsers/parser.c
parsers/parser.c:28: error: expected expression before ‘void’
make: *** [parsers/parser.o] Erreur 1
-
- Posts: 40
- Joined: Fri Mar 05, 2010 2:22 pm
Re: Setting up a FICS-like server
Perl problem is now ok .
But parser.c calls parse_info.h and i think this file is not correct
But parser.c calls parse_info.h and i think this file is not correct
-
- Posts: 27816
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Setting up a FICS-like server
Well, as parser-info.h is generated by the Perl script that produced the error above, I would not be surprised if it is corrupted.
As to the error you get in compiling parser.c:
This occurs at the beginning of line 28, which is immediately after the inclusion of parser_info.h. So it is likely that parser_info.h is incompletely generated, because the Perl script generating it aborted due to the error, and ends half-way in some C construct.
PerhapsI should check out how parser_info.h is supposed to look when I get no error message,and compare it to what you get. For that, however, I have to first boot up Linux.
As to the error you get in compiling parser.c:
Code: Select all
19 /*
20 automatic marshalling/unmarshalling system for C structures
21 */
22
23 #define EXTERN
24 #include "includes.h"
25 #include "parsers/parse_info.h"
26
27 /* load all the globals */
28 void load_all_globals(const char *fname)
29 {
...
PerhapsI should check out how parser_info.h is supposed to look when I get no error message,and compare it to what you get. For that, however, I have to first boot up Linux.
-
- Posts: 40
- Joined: Fri Mar 05, 2010 2:22 pm
Re: Setting up a FICS-like server
Yes i am sur that the file parser_info.h is incompletely generatedhgm wrote:Well, as parser-info.h is generated by the Perl script that produced the error above, I would not be surprised if it is corrupted.
As to the error you get in compiling parser.c:
This occurs at the beginning of line 28, which is immediately after the inclusion of parser_info.h. So it is likely that parser_info.h is incompletely generated, because the Perl script generating it aborted due to the error, and ends half-way in some C construct.Code: Select all
19 /* 20 automatic marshalling/unmarshalling system for C structures 21 */ 22 23 #define EXTERN 24 #include "includes.h" 25 #include "parsers/parse_info.h" 26 27 /* load all the globals */ 28 void load_all_globals(const char *fname) 29 { ...
PerhapsI should check out how parser_info.h is supposed to look when I get no error message,and compare it to what you get. For that, however, I have to first boot up Linux.
I created a user cheessd, i can give you by private message his password and my server ip
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: Setting up a FICS-like server
As to the perl script, line 181 is correct Perl so you may assume that the function around that line gets some bad input. The input is generated by the "gcc ..." command that is passed to genstruct.pl on the command line, as can be seen in genstruct.pl line 298:
So calling "parsers/genstruct.pl -o parsers/parse_info.h gcc -E -fPIC -Wall -g -O2 -DTDB_STANDALONE -I. -I./tdb includes.h" leads to this:
and the standard output of this command (in this case, the C preprocessor output since option -E is used) is passed as a long string to the "parse_data()" script function. This makes clear why results can vary between different systems: nobody guarantees that calling "gcc" will always produce exactly the same standard output.
If the original problem (incomplete generation of parse_info.h, probably due to some error popping up in line 181) persists then I would propose to compare the output of the "gcc ..." command line on different systems.
Sven
Code: Select all
parse_data(`@ARGV -DGENSTRUCT=GENSTRUCT`);
Code: Select all
gcc -E -fPIC -Wall -g -O2 -DTDB_STANDALONE -I. -I./tdb includes.h -DGENSTRUCT=GENSTRUCT
If the original problem (incomplete generation of parse_info.h, probably due to some error popping up in line 181) persists then I would propose to compare the output of the "gcc ..." command line on different systems.
Sven