Check-in Lasker-2.2.3 tar ball from samba.org
[capablanca.git] / lasker-2.2.3 / src / reload.c
1 /*
2   load/unload local variables
3
4    Copyright (C) Andrew Tridgell 2002
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "includes.h"
22
23 static void variable_reload(void)
24 {
25         if (config_open() != 0) {
26                 d_printf("CHESSD: config database open failed\n");
27                 exit(1);
28         }
29
30         news_open();
31         commands_init();
32         ratings_init();
33         wild_init();
34         book_open();
35         
36         init_userstat();
37 }
38
39 /* initialise variables that can be re-initialised on code reload */
40 void initial_load(void)
41 {
42         command_globals.startuptime = time(0);
43
44         seek_globals.quota_time = 60;
45         command_globals.player_high = 0;
46         command_globals.game_high = 0;
47         srandom(command_globals.startuptime);
48         variable_reload();
49 }
50
51 /* initialise variables that can be re-initialised on code reload */
52 void reload_open(void)
53 {
54         load_all_globals("globals.dat");
55         variable_reload();
56 }
57
58
59 /* initialise variables that can be re-initialised on code reload */
60 void reload_close(void)
61 {
62         news_close();
63         config_close();
64         book_close();
65         lists_close();
66         save_all_globals("globals.dat");
67         m_free_all();
68 }