cache.h 4.84 KB
Newer Older
Per Cederqvist's avatar
Per Cederqvist committed
1
/*
2
 * $Id: cache.h,v 0.9 1992/11/22 15:14:37 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. 
 */
/*
26
 * $Id: cache.h,v 0.9 1992/11/22 15:14:37 ceder Exp $
Per Cederqvist's avatar
Per Cederqvist committed
27
 *
Per Cederqvist's avatar
Per Cederqvist committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
 * This file contains the cached data that the server stores.
 * .h file created by ceder 1990-04-18
 */

/* cache_sync_all only returns when everything is written to disk. */
extern void
cache_sync_all(void);


/* First, some things which I want here. /ceder */

extern struct matching_info *match_table;

extern void
cached_lock_conf(Conf_no conf_no);

extern Success
init_cache(void);

extern void
cached_unlock_conf(Conf_no conf);

extern void
cached_lock_person(Pers_no pers);

extern void
cached_unlock_person(Pers_no pers);

extern Success
cached_delete_person(Pers_no pres);

extern Success
cached_delete_text(Text_no text);

extern Success
build_matching_info(void);

extern void			/* Write out everything. */
cache_sync(void);

/* S}d{r ja. Tack f|r mig. /ceder */

/*
 * Name caching routines
 */

/*
 * change_name changes the cached conference name. It is only called when
 * a conference name is changed or a conference is deleted.
 *
 * cached_change_name(foo, EMPTY_STRING); should be used when a conference
 * is deleted. (Eller ska det vara annorlunda? S} g|r jag nu... /ceder)
 */
extern void
cached_change_name(Conf_no name_num,
		   String  new_name );


extern Bool
cached_conf_exists( Conf_no conf_no );

/*
 * Calls for the cacheing of conf_type:
91 92
 * cached_get_conf_type() returns the type.
 * The type is set when mark_conference_as_changed is called.
Per Cederqvist's avatar
Per Cederqvist committed
93 94 95 96 97 98 99 100 101
 */

/* Get conference type */
/* Undefined result if the conf doesn't exist. */

extern Conf_type
cached_get_conf_type (Conf_no conf_no);

/*
102 103
 * Get garb_nice for a certain conference.
 * It is set when mark_conference_as_changed is called.
Per Cederqvist's avatar
Per Cederqvist committed
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
 */
extern Garb_nice
cached_get_garb_nice (Conf_no conf_no);

extern Local_text_no
cached_get_highest_local_no (Conf_no conf_no);



/*
 * Various function calls to tell the cache that something is changed.
 */

void
mark_person_as_changed(Pers_no	pers_no);


void
mark_conference_as_changed(Conf_no	conf_no);


void
mark_text_as_changed(Text_no	text_no);




/*
 * Person-related calls
 */

extern Success
cached_create_person( Pers_no person );



extern Person *
cached_get_person_stat( Pers_no	person );	/* Returns NULL if person
						   doesn't exist */



/*
 * Conference-related calls
 */
extern Conf_no
cached_create_conf( String  name );


extern Success
cached_delete_conf( Conf_no	conf );

extern Success
cached_lookup_name(const String   name,
		   Conf_list_old *result);

extern Conference *
cached_get_conf_stat(	Conf_no		conf_no );


/*
 * Calls to handle texts
 */

extern String
cached_get_text( Text_no text );/* The string should be free'd by the caller */

extern Text_stat *
cached_get_text_stat(	Text_no		text );


extern Text_no
cached_create_text( String message);

/*
 * traverse_text can be used to cycle through all existing texts. 0 will
 * be returned once in the "cycle".
 */
extern Text_no
traverse_text(Text_no seed);

/*
 * traverse_person can be used to cycle through all existing persons. 0 will
 * be returned once in the "cycle".
 */
extern Pers_no
traverse_person(Pers_no seed);

/*
 * traverse_conference can be used to cycle through all existing conferences.
 * 0 will be returned once in the "cycle".
 */
extern Conf_no
traverse_conference(Conf_no seed);
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212

/*
 * Free all memory used by the cache. This should only be done
 * as part of the shutdown sequence. The purpose of this is to
 * make it possible to see if there are any memory leaks.
 */

void
free_all_cache(void);

/*
 * Limit the number of 'clean' cache entries.
 */
void
cache_limit_size(void);
213 214 215 216 217 218 219 220 221 222 223 224

/*
 * Dump cache statistics.
 */

void
dump_cache_stats(FILE *stat_file);

/*
 * Dump memory usage.
 */
void
Per Cederqvist's avatar
Per Cederqvist committed
225
dump_cache_mem_usage(FILE *stat_file);
226 227 228 229 230 231

/*
 * Export the highest text_no for searching.
 */
int
query_next_text_num(void);
232 233 234 235 236 237 238

/*
 * Tell the cache that a text garbage collection operation is in progress
 * or is finished.
 */
void
tell_cache_garb_text(int running);