1 //
2 //	aegis - project change supervisor
3 //	Copyright (C) 2004-2006, 2008 Peter Miller
4 //
5 //	This program is free software; you can redistribute it and/or modify
6 //	it under the terms of the GNU General Public License as published by
7 //	the Free Software Foundation; either version 3 of the License, or
8 //	(at your option) any later version.
9 //
10 //	This program is distributed in the hope that it will be useful,
11 //	but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //	GNU General Public License for more details.
14 //
15 //	You should have received a copy of the GNU General Public License
16 //	along with this program. If not, see
17 //	<http://www.gnu.org/licenses/>.
18 //
19 
20 #include <common/ac/stdlib.h>
21 #include <libaegis/input/gunzip.h>
22 #include <libaegis/input/null.h>
23 
24 #include <aecvsserver/server.h>
25 #include <aecvsserver/net.h>
26 
27 
28 input
server_file_contents_get(server_ty * sp)29 server_file_contents_get(server_ty *sp)
30 {
31     nstring s;
32     if (!server_getline(sp, s))
33 	return new input_null();
34     const char *cp = s.c_str();
35     bool gunzip = false;
36     if (*cp == 'z')
37     {
38 	gunzip = true;
39 	++cp;
40     }
41     char *end = 0;
42     long length = strtol(cp, &end, 10);
43     if (end == cp || *end || length < 0)
44     {
45 	server_error(sp, "file length \"%s\" invalid", s.c_str());
46 	return new input_null();
47     }
48     input ip = sp->np->in_crop(length);
49     if (gunzip)
50 	ip = new input_gunzip(ip);
51     return ip;
52 }
53