Dillo v3.2.0-39-ge8be369a
Loading...
Searching...
No Matches
cache.h
Go to the documentation of this file.
1/*
2 * File: cache.c
3 *
4 * Copyright 2000-2009 Jorge Arellano Cid <jcid@dillo.org>
5 * Copyright 2025 Rodrigo Arias Mallo <rodarima@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 */
12
13#ifndef __CACHE_H__
14#define __CACHE_H__
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20
21#include "chain.h"
22#include "url.h"
23
24/*
25 * Cache Op codes
26 */
27#define CA_Send (0) /* Normal update */
28#define CA_Close (1) /* Successful operation close */
29#define CA_Abort (2) /* Operation abort */
30
31/*
32 * Flag Defines
33 */
34#define CA_GotHeader 0x1 /* True after header is completely got */
35#define CA_GotContentType 0x2 /* True after Content-Type is known */
36#define CA_GotLength 0x4 /* True if Content-Length is known */
37#define CA_InProgress 0x8 /* True if we are getting data */
38#define CA_Redirect 0x10 /* Data actually points to a redirect */
39#define CA_ForceRedirect 0x20 /* Unconditional redirect */
40#define CA_TempRedirect 0x40 /* Temporary redirect */
41#define CA_NotFound 0x80 /* True if remote server didn't find the URL */
42#define CA_Aborted 0x100 /* Aborted before getting full data */
43#define CA_MsgErased 0x200 /* Used to erase the bw's status bar */
44#define CA_RedirectLoop 0x400 /* Redirect loop */
45#define CA_InternalUrl 0x800 /* URL content is generated by dillo */
46#define CA_HugeFile 0x1000 /* URL content is too big */
47#define CA_IsEmpty 0x2000 /* True until a byte of content arrives */
48#define CA_KeepAlive 0x4000
49
51
55typedef void (*CA_Callback_t)(int Op, CacheClient_t *Client);
56
70
71/*
72 * Function prototypes
73 */
74void a_Cache_init(void);
75void a_Cache_entry_inject(const DilloUrl *Url, Dstr *data_ds);
76int a_Cache_open_url(void *Web, CA_Callback_t Call, void *CbData);
77int a_Cache_get_buf(const DilloUrl *Url, char **PBuf, int *BufSize);
78void a_Cache_unref_buf(const DilloUrl *Url);
79const char *a_Cache_get_content_type(const DilloUrl *url);
80const char *a_Cache_set_content_type(const DilloUrl *url, const char *ctype,
81 const char *from);
84bool_t a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size,
85 const DilloUrl *Url);
88void a_Cache_freeall(void);
90void a_Cache_stop_client(int Key);
91
92
93#ifdef __cplusplus
94}
95#endif /* __cplusplus */
96#endif /* __CACHE_H__ */
97
int a_Cache_get_buf(const DilloUrl *Url, char **PBuf, int *BufSize)
Get the pointer to the URL document, and its size, from the cache entry.
Definition cache.c:554
CacheClient_t * a_Cache_client_get_if_unique(int Key)
Last Client for this entry?
Definition cache.c:1417
uint_t a_Cache_get_flags_with_redirection(const DilloUrl *url)
Get cache entry status (following redirections).
Definition cache.c:417
void(* CA_Callback_t)(int Op, CacheClient_t *Client)
Callback type for cache clients.
Definition cache.h:55
const char * a_Cache_set_content_type(const DilloUrl *url, const char *ctype, const char *from)
Change Content-Type for cache entry found by url.
Definition cache.c:494
void a_Cache_unref_buf(const DilloUrl *Url)
Unreference the data buffer when no longer using it.
Definition cache.c:573
const char * a_Cache_get_content_type(const DilloUrl *url)
Get current Content-Type for cache entry found by URL.
Definition cache.c:474
void a_Cache_entry_remove_by_url(DilloUrl *url)
Wrapper for capi.
Definition cache.c:359
bool_t a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size, const DilloUrl *Url)
Receive new data, update the reception buffer (for next read), update the cache, and service the clie...
Definition cache.c:902
int a_Cache_download_enabled(const DilloUrl *url)
Check whether a URL scheme is downloadable.
Definition cache.c:1098
int a_Cache_open_url(void *Web, CA_Callback_t Call, void *CbData)
Try finding the url in the cache.
Definition cache.c:378
void a_Cache_init(void)
Initialize cache data.
Definition cache.c:118
void a_Cache_entry_inject(const DilloUrl *Url, Dstr *data_ds)
Inject full page content directly into the cache.
Definition cache.c:270
void a_Cache_freeall(void)
Memory deallocator (only called at exit time)
Definition cache.c:1466
uint_t a_Cache_get_flags(const DilloUrl *url)
Get cache entry status.
Definition cache.c:408
void a_Cache_stop_client(int Key)
Remove a client from the client queue TODO: notify the dicache and upper layers.
Definition cache.c:1437
unsigned int uint_t
Definition d_size.h:20
unsigned char bool_t
Definition d_size.h:21
Data structure for cache clients.
Definition cache.h:60
CA_Callback_t Callback
Client function.
Definition cache.h:66
const DilloUrl * Url
Pointer to a cache entry Url.
Definition cache.h:62
int Key
Primary Key for this client.
Definition cache.h:61
int Version
Dicache version of this Url (0 if not used)
Definition cache.h:63
void * CbData
Client function data.
Definition cache.h:67
uint_t BufSize
Valid size of cache-data.
Definition cache.h:65
void * Buf
Pointer to cache-data.
Definition cache.h:64
void * Web
Pointer to the Web structure of our client.
Definition cache.h:68
Definition url.h:88
Definition dlib.h:102
Parse and normalize all URL's inside Dillo.