libwebsockets
Lightweight C library for HTML5 websockets
lws-diskcache.h
Go to the documentation of this file.
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  */
24 
60 
61 struct lws_diskcache_scan;
62 
73 LWS_VISIBLE LWS_EXTERN struct lws_diskcache_scan *
74 lws_diskcache_create(const char *cache_dir_base, uint64_t cache_size_limit);
75 
85 lws_diskcache_destroy(struct lws_diskcache_scan **lds);
86 
103 lws_diskcache_prepare(const char *cache_base_dir, int mode, uid_t uid);
104 
105 #define LWS_DISKCACHE_QUERY_NO_CACHE 0
106 #define LWS_DISKCACHE_QUERY_EXISTS 1
107 #define LWS_DISKCACHE_QUERY_CREATING 2
108 #define LWS_DISKCACHE_QUERY_ONGOING 3 /* something else is creating it */
109 
141 lws_diskcache_query(struct lws_diskcache_scan *lds, int is_bot,
142  const char *hash_hex, int *_fd, char *cache, int cache_len,
143  size_t *extant_cache_len);
144 
157 
174 lws_diskcache_trim(struct lws_diskcache_scan *lds);
175 
176 
186 lws_diskcache_secs_to_idle(struct lws_diskcache_scan *lds);
LWS_VISIBLE LWS_EXTERN int lws_diskcache_trim(struct lws_diskcache_scan *lds)
LWS_VISIBLE LWS_EXTERN int lws_diskcache_prepare(const char *cache_base_dir, int mode, uid_t uid)
LWS_VISIBLE LWS_EXTERN int lws_diskcache_secs_to_idle(struct lws_diskcache_scan *lds)
LWS_VISIBLE LWS_EXTERN void lws_diskcache_destroy(struct lws_diskcache_scan **lds)
LWS_VISIBLE LWS_EXTERN int lws_diskcache_finalize_name(char *cache)
LWS_VISIBLE LWS_EXTERN struct lws_diskcache_scan * lws_diskcache_create(const char *cache_dir_base, uint64_t cache_size_limit)
LWS_VISIBLE LWS_EXTERN int lws_diskcache_query(struct lws_diskcache_scan *lds, int is_bot, const char *hash_hex, int *_fd, char *cache, int cache_len, size_t *extant_cache_len)
#define LWS_EXTERN
#define LWS_VISIBLE