cache.h 4.49 KB
Newer Older
Per Cederqvist's avatar
Per Cederqvist committed
1
/*
2
3
 * $Id: cache.h,v 0.20 1999/05/24 09:34:20 ceder Exp $
 * Copyright (C) 1991-1996, 1999  Lysator Academic Computer Association.
Linus Tolke's avatar
Linus Tolke committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 *
 * This file is part of the LysKOM server.
 * 
 * LysKOM 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 1, or (at your option) 
 * any later version.
 * 
 * LysKOM is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with LysKOM; see the file COPYING.  If not, write to
 * Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
 * or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
 * MA 02139, USA.
 *
 * Please mail bug reports to bug-lyskom@lysator.liu.se. 
 */
/*
Pontus Hagland's avatar
Pontus Hagland committed
26
 * database cache header file
Per Cederqvist's avatar
Per Cederqvist committed
27
28
 */

29
extern struct matching_info *match_table;
Pontus Hagland's avatar
Pontus Hagland committed
30
/* match_table, see build_matching_info() */
Per Cederqvist's avatar
Per Cederqvist committed
31
32


Pontus Hagland's avatar
Pontus Hagland committed
33
/******** initiation and shutdown of cache *******************************/
Per Cederqvist's avatar
Per Cederqvist committed
34

Pontus Hagland's avatar
Pontus Hagland committed
35
/* initiate cache (called at initiation/startup of server) */
36
Success init_cache(void);           
Per Cederqvist's avatar
Per Cederqvist committed
37

Pontus Hagland's avatar
Pontus Hagland committed
38
/* flush, shutdown cache and free all cache memory (called at shutdown) */
39
void free_all_cache(void);
Per Cederqvist's avatar
Per Cederqvist committed
40

Pontus Hagland's avatar
Pontus Hagland committed
41
/* dump emergency files, etc, if possible */
42
void cache_emergency_exit(void);
Per Cederqvist's avatar
Per Cederqvist committed
43

Pontus Hagland's avatar
Pontus Hagland committed
44
/******** miscellanous cache master routines *****************************/
Per Cederqvist's avatar
Per Cederqvist committed
45

Pontus Hagland's avatar
Pontus Hagland committed
46
/* end-of-atomic, may clear read entries */
47
void cache_limit_size(void);
Per Cederqvist's avatar
Per Cederqvist committed
48

Pontus Hagland's avatar
Pontus Hagland committed
49
/* sync timout routine, TRUE=>long timeout before next */
50
Bool sync_part(void);
Per Cederqvist's avatar
Per Cederqvist committed
51

Pontus Hagland's avatar
Pontus Hagland committed
52
/* flush all & wait until disk is synced */
53
void cache_sync_all(void);
Per Cederqvist's avatar
Per Cederqvist committed
54

Pontus Hagland's avatar
Pontus Hagland committed
55
/* tell cache that garb_text is in progress, ie never flush cache */
56
void tell_cache_garb_text(int running);
Per Cederqvist's avatar
Per Cederqvist committed
57

58
/* dump cache statistics etc */
Pontus Hagland's avatar
Pontus Hagland committed
59
60
void dump_cache_stats(FILE *stat_file);
void dump_cache_mem_usage(FILE *stat_file);
Per Cederqvist's avatar
Per Cederqvist committed
61

Pontus Hagland's avatar
Pontus Hagland committed
62
/******** object manipulation routines ***********************************/
Per Cederqvist's avatar
Per Cederqvist committed
63

64
/* mark as changed (object is to be re-written to disk) */
Pontus Hagland's avatar
Pontus Hagland committed
65
66
67
void        mark_person_as_changed(Pers_no pers);
void        mark_text_as_changed(Text_no text);
void        mark_conference_as_changed(Conf_no conf);
Per Cederqvist's avatar
Per Cederqvist committed
68

69
/* lock (do never remove object from memory) & unlock */
Pontus Hagland's avatar
Pontus Hagland committed
70
71
72
73
void        cached_lock_conf(Conf_no conf);
void        cached_unlock_conf(Conf_no conf);
void        cached_lock_person(Pers_no pers);
void        cached_unlock_person(Pers_no pers);
Per Cederqvist's avatar
Per Cederqvist committed
74

75
/* create object (returns FALSE if person existed) */
Pontus Hagland's avatar
Pontus Hagland committed
76
77
78
Success     cached_create_person(Pers_no pers);
Conf_no     cached_create_conf(String name);
Text_no     cached_create_text(const String message);
Per Cederqvist's avatar
Per Cederqvist committed
79

80
/* get object from database */
Pontus Hagland's avatar
Pontus Hagland committed
81
82
83
Person     *cached_get_person_stat(Pers_no person);
Conference *cached_get_conf_stat(Conf_no conf);
Text_stat  *cached_get_text_stat(Text_no text);
84
Small_conf *cached_get_small_conf_stat(Conf_no conf_no);
Per Cederqvist's avatar
Per Cederqvist committed
85

Pontus Hagland's avatar
Pontus Hagland committed
86
/* return text. String is to be freed by caller */
87
String      cached_get_text(Text_no text);
88

89
/* remove object from database */
Pontus Hagland's avatar
Pontus Hagland committed
90
91
92
Success     cached_delete_person(Pers_no pers);
Success     cached_delete_text(Text_no text);
Success     cached_delete_conf(Conf_no conf);
Per Cederqvist's avatar
Per Cederqvist committed
93

94
/* return number of next existing object */
Pontus Hagland's avatar
Pontus Hagland committed
95
96
97
Pers_no     traverse_person(Pers_no sead);
Conf_no     traverse_conference(Conf_no sead);
Text_no     traverse_text(Text_no sead);
98

Pontus Hagland's avatar
Pontus Hagland committed
99
/* returns highest text_num +1 */
100
Text_no     query_next_text_num(void);
Per Cederqvist's avatar
Per Cederqvist committed
101

Pontus Hagland's avatar
Pontus Hagland committed
102
/******** misc conference routines **************************************/
Per Cederqvist's avatar
Per Cederqvist committed
103

104
/* Change conferance name.
Pontus Hagland's avatar
Pontus Hagland committed
105
   cached_change_name(foo,EMPTY_STRING);
106
107
   is used when a conference is deleted. */
void      cached_change_name(Conf_no conf,String new_name);
Per Cederqvist's avatar
Per Cederqvist committed
108

Pontus Hagland's avatar
Pontus Hagland committed
109
/* returns TRUE when a conference exists */
110
Bool      cached_conf_exists(Conf_no conf);
Per Cederqvist's avatar
Per Cederqvist committed
111

112
/* returns conference type.
Pontus Hagland's avatar
Pontus Hagland committed
113
   conf_type is set when mark_conference_as_changed is called (?) */
114
Conf_type cached_get_conf_type(Conf_no conf);
Per Cederqvist's avatar
Per Cederqvist committed
115

Pontus Hagland's avatar
Pontus Hagland committed
116
/* Get garb_nice from smallconf  */
117
Garb_nice cached_get_garb_nice(Conf_no conf);
Per Cederqvist's avatar
Per Cederqvist committed
118

Pontus Hagland's avatar
Pontus Hagland committed
119
/* returns conference name from smallconf */
120
String    cached_get_name(Conf_no conf);
Per Cederqvist's avatar
Per Cederqvist committed
121

Pontus Hagland's avatar
Pontus Hagland committed
122
/* returns highes text number in a certain conference */
123
Local_text_no cached_get_highest_local_no(Conf_no conf);
Per Cederqvist's avatar
Per Cederqvist committed
124

Pontus Hagland's avatar
Pontus Hagland committed
125
/* match from name => conf_list_old */
126
127
128
129
Success   cached_lookup_name(const String name,Conf_list_old *result);

/* How many conferences exists?  */
Conf_no   cached_no_of_existing_conferences(void);
Per Cederqvist's avatar
Per Cederqvist committed
130

Pontus Hagland's avatar
Pontus Hagland committed
131
/******** miscellanous wierd routines ************************************/
Per Cederqvist's avatar
Per Cederqvist committed
132

Pontus Hagland's avatar
Pontus Hagland committed
133
Success build_matching_info(void);
Per Cederqvist's avatar
Per Cederqvist committed
134