cache.h 4.48 KB
Newer Older
Per Cederqvist's avatar
Per Cederqvist committed
1
/*
2
 * $Id: cache.h,v 0.13 1994/02/20 16:21:15 ceder Exp $
Linus Tolke Y's avatar
Linus Tolke Y committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 * Copyright (C) 1991  Lysator Academic Computer Association.
 *
 * 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
 */

Pontus Hagland's avatar
Pontus Hagland committed
29 30
struct matching_info *match_table;
/* 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
/* flush all, dont wait for disk */
50
void cache_sync(void);
Per Cederqvist's avatar
Per Cederqvist committed
51

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

Pontus Hagland's avatar
Pontus Hagland committed
55
/* flush all & wait until disk is synced */
56
void cache_sync_all(void);
Per Cederqvist's avatar
Per Cederqvist committed
57

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

61
/* dump cache statistics etc */
Pontus Hagland's avatar
Pontus Hagland committed
62 63
void dump_cache_stats(FILE *stat_file);
void dump_cache_mem_usage(FILE *stat_file);
Per Cederqvist's avatar
Per Cederqvist committed
64

Pontus Hagland's avatar
Pontus Hagland committed
65
/******** object manipulation routines ***********************************/
Per Cederqvist's avatar
Per Cederqvist committed
66

67
/* mark as changed (object is to be re-written to disk) */
Pontus Hagland's avatar
Pontus Hagland committed
68 69 70
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
71

72
/* lock (do never remove object from memory) & unlock */
Pontus Hagland's avatar
Pontus Hagland committed
73 74 75 76
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
77

78
/* create object (returns FALSE if person existed) */
Pontus Hagland's avatar
Pontus Hagland committed
79 80 81
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
82

83
/* get object from database */
Pontus Hagland's avatar
Pontus Hagland committed
84 85 86
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);
Per Cederqvist's avatar
Per Cederqvist committed
87

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

91
/* remove object from database */
Pontus Hagland's avatar
Pontus Hagland committed
92 93 94
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
95

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

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

Pontus Hagland's avatar
Pontus Hagland committed
104
/******** misc conference routines **************************************/
Per Cederqvist's avatar
Per Cederqvist committed
105

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

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

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

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

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

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

Pontus Hagland's avatar
Pontus Hagland committed
127
/* match from name => conf_list_old */
128 129 130 131
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
132

Pontus Hagland's avatar
Pontus Hagland committed
133
/******** miscellanous wierd routines ************************************/
Per Cederqvist's avatar
Per Cederqvist committed
134

Pontus Hagland's avatar
Pontus Hagland committed
135
Success build_matching_info(void);
Per Cederqvist's avatar
Per Cederqvist committed
136