cache.h 4.39 KB
Newer Older
Per Cederqvist's avatar
Per Cederqvist committed
1
/*
Pontus Hagland's avatar
Pontus Hagland committed
2
 * $Id: cache.h,v 0.12 1994/02/20 14:14:15 law 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 36
Success init_cache(void);           
/* initiate cache (called at initiation/startup of server) */
Per Cederqvist's avatar
Per Cederqvist committed
37

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

Pontus Hagland's avatar
Pontus Hagland committed
41 42
void cache_emergency_exit(void);
/* dump emergency files, etc, if possible */
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 47
void cache_limit_size(void);
/* end-of-atomic, may clear read entries */
Per Cederqvist's avatar
Per Cederqvist committed
48

Pontus Hagland's avatar
Pontus Hagland committed
49 50
void cache_sync(void);
/* flush all, dont wait for disk */
Per Cederqvist's avatar
Per Cederqvist committed
51

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

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

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

Pontus Hagland's avatar
Pontus Hagland committed
61 62 63
void dump_cache_stats(FILE *stat_file);
void dump_cache_mem_usage(FILE *stat_file);
/* dump cache statistics etc */
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

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

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

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

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

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

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

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

Pontus Hagland's avatar
Pontus Hagland committed
101 102
Text_no     query_next_text_num(void);
/* returns highest text_num +1 */
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

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

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

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

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

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

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

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

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

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