Dillo v3.1.1-98-g318d1f14
Loading...
Searching...
No Matches
cache.h File Reference
#include "chain.h"
#include "url.h"
Include dependency graph for cache.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CacheClient
 Data structure for cache clients. More...
 

Macros

#define CA_Send   (0) /* Normal update */
 
#define CA_Close   (1) /* Successful operation close */
 
#define CA_Abort   (2) /* Operation abort */
 
#define CA_GotHeader   0x1 /* True after header is completely got */
 
#define CA_GotContentType   0x2 /* True after Content-Type is known */
 
#define CA_GotLength   0x4 /* True if Content-Length is known */
 
#define CA_InProgress   0x8 /* True if we are getting data */
 
#define CA_Redirect   0x10 /* Data actually points to a redirect */
 
#define CA_ForceRedirect   0x20 /* Unconditional redirect */
 
#define CA_TempRedirect   0x40 /* Temporary redirect */
 
#define CA_NotFound   0x80 /* True if remote server didn't find the URL */
 
#define CA_Aborted   0x100 /* Aborted before getting full data */
 
#define CA_MsgErased   0x200 /* Used to erase the bw's status bar */
 
#define CA_RedirectLoop   0x400 /* Redirect loop */
 
#define CA_InternalUrl   0x800 /* URL content is generated by dillo */
 
#define CA_HugeFile   0x1000 /* URL content is too big */
 
#define CA_IsEmpty   0x2000 /* True until a byte of content arrives */
 
#define CA_KeepAlive   0x4000
 

Typedefs

typedef struct CacheClient CacheClient_t
 
typedef void(* CA_Callback_t) (int Op, CacheClient_t *Client)
 Callback type for cache clients.
 

Functions

void a_Cache_init (void)
 Initialize cache data.
 
int a_Cache_open_url (void *Web, CA_Callback_t Call, void *CbData)
 Try finding the url in the cache.
 
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.
 
void a_Cache_unref_buf (const DilloUrl *Url)
 Unreference the data buffer when no longer using it.
 
const char * a_Cache_get_content_type (const DilloUrl *url)
 Get current Content-Type for cache entry found by URL.
 
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.
 
uint_t a_Cache_get_flags (const DilloUrl *url)
 Get cache entry status.
 
uint_t a_Cache_get_flags_with_redirection (const DilloUrl *url)
 Get cache entry status (following redirections).
 
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 client queue.
 
int a_Cache_download_enabled (const DilloUrl *url)
 Check whether a URL scheme is downloadable.
 
void a_Cache_entry_remove_by_url (DilloUrl *url)
 Wrapper for capi.
 
void a_Cache_freeall (void)
 Memory deallocator (only called at exit time)
 
CacheClient_ta_Cache_client_get_if_unique (int Key)
 Last Client for this entry?
 
void a_Cache_stop_client (int Key)
 Remove a client from the client queue TODO: notify the dicache and upper layers.
 

Macro Definition Documentation

◆ CA_Abort

#define CA_Abort   (2) /* Operation abort */

Definition at line 17 of file cache.h.

◆ CA_Aborted

#define CA_Aborted   0x100 /* Aborted before getting full data */

Definition at line 30 of file cache.h.

◆ CA_Close

#define CA_Close   (1) /* Successful operation close */

Definition at line 16 of file cache.h.

◆ CA_ForceRedirect

#define CA_ForceRedirect   0x20 /* Unconditional redirect */

Definition at line 27 of file cache.h.

◆ CA_GotContentType

#define CA_GotContentType   0x2 /* True after Content-Type is known */

Definition at line 23 of file cache.h.

◆ CA_GotHeader

#define CA_GotHeader   0x1 /* True after header is completely got */

Definition at line 22 of file cache.h.

◆ CA_GotLength

#define CA_GotLength   0x4 /* True if Content-Length is known */

Definition at line 24 of file cache.h.

◆ CA_HugeFile

#define CA_HugeFile   0x1000 /* URL content is too big */

Definition at line 34 of file cache.h.

◆ CA_InProgress

#define CA_InProgress   0x8 /* True if we are getting data */

Definition at line 25 of file cache.h.

◆ CA_InternalUrl

#define CA_InternalUrl   0x800 /* URL content is generated by dillo */

Definition at line 33 of file cache.h.

◆ CA_IsEmpty

#define CA_IsEmpty   0x2000 /* True until a byte of content arrives */

Definition at line 35 of file cache.h.

◆ CA_KeepAlive

#define CA_KeepAlive   0x4000

Definition at line 36 of file cache.h.

◆ CA_MsgErased

#define CA_MsgErased   0x200 /* Used to erase the bw's status bar */

Definition at line 31 of file cache.h.

◆ CA_NotFound

#define CA_NotFound   0x80 /* True if remote server didn't find the URL */

Definition at line 29 of file cache.h.

◆ CA_Redirect

#define CA_Redirect   0x10 /* Data actually points to a redirect */

Definition at line 26 of file cache.h.

◆ CA_RedirectLoop

#define CA_RedirectLoop   0x400 /* Redirect loop */

Definition at line 32 of file cache.h.

◆ CA_Send

#define CA_Send   (0) /* Normal update */

Definition at line 15 of file cache.h.

◆ CA_TempRedirect

#define CA_TempRedirect   0x40 /* Temporary redirect */

Definition at line 28 of file cache.h.

Typedef Documentation

◆ CA_Callback_t

typedef void(* CA_Callback_t) (int Op, CacheClient_t *Client)

Callback type for cache clients.

Definition at line 43 of file cache.h.

◆ CacheClient_t

typedef struct CacheClient CacheClient_t

Definition at line 38 of file cache.h.

Function Documentation

◆ a_Cache_client_get_if_unique()

CacheClient_t * a_Cache_client_get_if_unique ( int  Key)

Last Client for this entry?

Returns
Client if true, NULL otherwise (cache.c has only one call to a capi function. This avoids a second one)

Definition at line 1399 of file cache.c.

References Cache_client_by_key_cmp(), ClientQueue, dList_find_custom(), dList_nth_data(), INT2VOIDP, and CacheClient::Url.

Referenced by a_Capi_stop_client().

◆ a_Cache_download_enabled()

int a_Cache_download_enabled ( const DilloUrl url)

Check whether a URL scheme is downloadable.

Returns
1 enabled, 0 disabled.

Definition at line 1093 of file cache.c.

References dStrAsciiCasecmp(), and URL_SCHEME.

Referenced by a_Capi_open_url(), and Cache_process_queue().

◆ a_Cache_entry_remove_by_url()

void a_Cache_entry_remove_by_url ( DilloUrl url)

Wrapper for capi.

Definition at line 357 of file cache.c.

References Cache_entry_remove().

Referenced by a_Capi_ccc().

◆ a_Cache_freeall()

void a_Cache_freeall ( void  )

Memory deallocator (only called at exit time)

Definition at line 1448 of file cache.c.

References Cache_client_dequeue(), Cache_entry_free(), CachedURLs, ClientQueue, dList_free(), dList_nth_data(), and dList_remove_fast().

Referenced by main().

◆ a_Cache_get_buf()

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.

Returns
1 cached, 0 not cached.

Definition at line 552 of file cache.c.

References Cache_data(), Cache_entry_search_with_redirect(), Cache_ref_data(), Dstr::len, and Dstr::str.

Referenced by a_Capi_get_buf().

◆ a_Cache_get_content_type()

const char * a_Cache_get_content_type ( const DilloUrl url)

Get current Content-Type for cache entry found by URL.

Definition at line 472 of file cache.c.

References Cache_current_content_type(), and Cache_entry_search_with_redirect().

Referenced by a_Capi_get_content_type().

◆ a_Cache_get_flags()

uint_t a_Cache_get_flags ( const DilloUrl url)

Get cache entry status.

Definition at line 406 of file cache.c.

References Cache_entry_search().

Referenced by a_Capi_get_flags().

◆ a_Cache_get_flags_with_redirection()

uint_t a_Cache_get_flags_with_redirection ( const DilloUrl url)

Get cache entry status (following redirections).

Definition at line 415 of file cache.c.

References Cache_entry_search_with_redirect().

Referenced by a_Capi_get_flags_with_redirection().

◆ a_Cache_init()

void a_Cache_init ( void  )

Initialize cache data.

Definition at line 118 of file cache.c.

References a_Url_free(), a_Url_new(), AboutSplash, Cache_entry_inject(), CachedURLs, ClientQueue, DelayedQueue, dList_new(), dStr_free(), and dStr_new().

Referenced by a_Capi_init().

◆ a_Cache_open_url()

int a_Cache_open_url ( void *  web,
CA_Callback_t  Call,
void *  CbData 
)

Try finding the url in the cache.

If it hits, send the cache contents from there. If it misses, set up a new connection.

  • 'Web' is an auxiliary data structure with misc. parameters.
  • 'Call' is the callback that receives the data
  • 'CbData' is custom data passed to 'Call' Note: 'Call' and/or 'CbData' can be NULL, in that case they get set later by a_Web_dispatch_by_type, based on content/type and 'Web' data.
Returns
A primary key for identifying the client,

Definition at line 376 of file cache.c.

References Cache_client_enqueue(), Cache_delayed_process_queue(), Cache_entry_add(), Cache_entry_remove(), Cache_entry_search(), _DilloWeb::url, URL_E2EQuery, and URL_FLAGS.

Referenced by a_Capi_open_url().

◆ a_Cache_process_dbuf()

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 client queue.

This function gets called whenever the IO has new data. 'Op' is the operation to perform 'VPtr' is a (void) pointer to the IO control structure

Definition at line 897 of file cache.c.

References _MSG, a_Bw_remove_client(), a_Decode_process(), a_Decode_transfer_finished(), a_Decode_transfer_process(), _DilloWeb::bw, CA_Aborted, CA_GotHeader, CA_GotLength, CA_KeepAlive, Cache_client_dequeue(), Cache_entry_search(), Cache_finish_msg(), Cache_get_header(), Cache_parse_header(), Cache_process_queue(), ClientQueue, dList_nth_data(), dReturn_val_if_fail, dStr_append_l(), dStr_free(), FALSE, IOAbort, IOClose, IORead, CacheClient::Key, Dstr::len, MSG, Dstr::str, TRUE, CacheClient::Url, URL_STR, and CacheClient::Web.

Referenced by a_Capi_ccc().

◆ a_Cache_set_content_type()

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.

from = { "http" | "meta" }

Returns
new content type.

Definition at line 492 of file cache.c.

References _MSG, a_Decode_charset_init(), a_Decode_free(), a_Misc_content_type_cmp(), a_Misc_parse_content_type(), Cache_current_content_type(), Cache_entry_search(), dFree(), dReturn_val_if_fail, dStr_free(), dStrconcat(), dStrdup(), dStrnAsciiCasecmp(), and URL_STR.

Referenced by a_Capi_set_content_type(), and Cache_parse_header().

◆ a_Cache_stop_client()

void a_Cache_stop_client ( int  Key)

Remove a client from the client queue TODO: notify the dicache and upper layers.

Definition at line 1419 of file cache.c.

References _MSG, a_Dicache_get_entry(), a_Dicache_unref(), Cache_client_by_key_cmp(), Cache_client_dequeue(), Cache_entry_search(), ClientQueue, DelayedQueue, dList_find_custom(), dList_remove(), INT2VOIDP, CacheClient::Url, and CacheClient::Version.

Referenced by a_Capi_stop_client(), and Cache_entry_remove().

◆ a_Cache_unref_buf()

void a_Cache_unref_buf ( const DilloUrl Url)

Unreference the data buffer when no longer using it.

Definition at line 571 of file cache.c.

References Cache_entry_search_with_redirect(), and Cache_unref_data().

Referenced by a_Capi_unref_buf().