1 /* vim:tw=78:ts=8:sw=4:set ft=c: */
3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 Ben Kibbey <bjk@luxsci.net>
6 This file is part of pwmd.
8 Pwmd is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
13 Pwmd is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Pwmd. If not, see <http://www.gnu.org/licenses/>.
25 #include <gpg-error.h>
30 gpointer pubkey
; /* needed for SAVE */
31 gpointer sigkey
; /* needed for SAVE */
32 gpointer doc
; /* AES-128 encrypted */
34 guchar
*crc
; /* Checksum of the data file. */
38 guchar filename
[16]; /* MD5 hash. */
39 guchar grip
[41]; /* key grip for this file */
40 gint timeout
; /* cache_timer_thread(). */
41 gint reset
; /* To reset .timeout. */
42 gboolean defer_clear
; /* Another thread wants to clear the cache
43 entry for this file. Prevent resetting the
44 timer until this flag is cleared. */
45 pthread_mutex_t
*mutex
; /* Data file mutex. */
46 struct cache_data_s
*data
;
52 gsize cache_blocksize
;
55 void cache_adjust_timeout();
56 gpg_error_t
cache_set_timeout(const guchar
*md5filename
, gint timeout
);
57 gpg_error_t
cache_iscached(const gchar
*filename
, gboolean
*defer
);
58 gpg_error_t
cache_clear(const guchar
*md5filename
);
59 gboolean
cache_add_file(const guchar
*md5file
, const guchar
*grip
,
60 struct cache_data_s
*, gint timeout
);
62 gpg_error_t
cache_init();
63 guint
cache_file_count();
64 struct cache_data_s
*cache_get_data(const guchar
*md5file
);
65 gpg_error_t
cache_set_data(const guchar
*md5file
, struct cache_data_s
*,
67 gpg_error_t
cache_is_shadowed(const gchar
*grip
);
68 gpg_error_t
cache_lock_mutex(gpointer ctx
, const guchar
*md5file
,
69 glong mutex_timeout
, gboolean add
, gint timeout
);
70 gpg_error_t
cache_unlock_mutex(const guchar
*md5file
, gboolean remove
);
73 void free_cache_data_once(struct cache_data_s
*data
);
74 gpg_error_t
cache_defer_clear(const guchar
*md5file
);