Dillo v3.1.1-98-g318d1f14
Loading...
Searching...
No Matches
cookies.c File Reference

Handling of cookies takes place here. More...

#include "msg.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
#include "IO/Url.h"
#include "list.h"
#include "cookies.h"
#include "capi.h"
#include "../dpip/dpip.h"
Include dependency graph for cookies.c:

Go to the source code of this file.

Macros

#define LINE_MAXLEN   4096
 The maximum length of a line in the cookie file.
 

Enumerations

enum  CookieControlAction { COOKIE_ACCEPT , COOKIE_ACCEPT_SESSION , COOKIE_DENY }
 

Functions

static FILE * Cookies_fopen (const char *filename, char *init_str)
 Return a file pointer.
 
static CookieControlAction Cookies_control_check (const DilloUrl *url)
 Same as Cookies_control_check_domain except it takes an URL.
 
static CookieControlAction Cookies_control_check_domain (const char *domain)
 Check the rules for an appropriate action for this domain.
 
static int Cookie_control_init (void)
 Get the cookie control rules (from cookiesrc).
 
void a_Cookies_init (void)
 Initialize the cookies module (The 'disabled' variable is writable only within a_Cookies_init)
 
void a_Cookies_freeall (void)
 Flush cookies to disk and free all the memory allocated.
 
void a_Cookies_set (Dlist *cookie_strings, const DilloUrl *set_url, const char *date)
 Set the value corresponding to the cookie string.
 
char * a_Cookies_get_query (const DilloUrl *query_url, const DilloUrl *requester)
 Return a string containing cookie data for an HTTP query.
 

Variables

static CookieControl * ccontrol = NULL
 
static int num_ccontrol = 0
 
static int num_ccontrol_max = 1
 
static CookieControlAction default_action = COOKIE_DENY
 
static bool_t disabled
 

Detailed Description

Handling of cookies takes place here.

Definition in file cookies.c.

Macro Definition Documentation

◆ LINE_MAXLEN

#define LINE_MAXLEN   4096

The maximum length of a line in the cookie file.

Definition at line 50 of file cookies.c.

Enumeration Type Documentation

◆ CookieControlAction

Enumerator
COOKIE_ACCEPT 
COOKIE_ACCEPT_SESSION 
COOKIE_DENY 

Definition at line 52 of file cookies.c.

Function Documentation

◆ a_Cookies_freeall()

void a_Cookies_freeall ( void  )

Flush cookies to disk and free all the memory allocated.

Definition at line 135 of file cookies.c.

Referenced by main().

◆ a_Cookies_get_query()

char * a_Cookies_get_query ( const DilloUrl query_url,
const DilloUrl requester 
)

Return a string containing cookie data for an HTTP query.

Definition at line 185 of file cookies.c.

References _MSG, a_Dpi_send_blocking_cmd(), a_Dpip_build_cmd(), a_Dpip_get_attr(), a_Url_same_organization(), COOKIE_DENY, Cookies_control_check(), dFree(), disabled, dStrdup(), MSG, path(), URL_HOST, URL_HOST_, URL_PATH_, and URL_SCHEME.

Referenced by expect(), Http_make_query_str(), and main().

◆ a_Cookies_init()

void a_Cookies_init ( void  )

Initialize the cookies module (The 'disabled' variable is writable only within a_Cookies_init)

Definition at line 117 of file cookies.c.

References Cookie_control_init(), disabled, FALSE, MSG, and TRUE.

Referenced by main().

◆ a_Cookies_set()

void a_Cookies_set ( Dlist cookie_strings,
const DilloUrl set_url,
const char *  date 
)

◆ Cookie_control_init()

static int Cookie_control_init ( void  )
static

Get the cookie control rules (from cookiesrc).

Returns
  • 0 = Parsed OK, with cookies enabled
  • 1 = Parsed OK, with cookies disabled
  • 2 = Can't open the control file

Definition at line 241 of file cookies.c.

References a_List_add, ccontrol, COOKIE_ACCEPT, COOKIE_ACCEPT_SESSION, COOKIE_DENY, Cookies_fopen(), default_action, dFree(), dGethomedir(), dIsspace, dStrAsciiCasecmp(), dStrconcat(), dStrdup(), dStrerror, dStrstrip(), FALSE, LINE_MAXLEN, MSG, num_ccontrol, num_ccontrol_max, and TRUE.

◆ Cookies_control_check()

static CookieControlAction Cookies_control_check ( const DilloUrl url)
static

Same as Cookies_control_check_domain except it takes an URL.

Definition at line 365 of file cookies.c.

References Cookies_control_check_domain(), and URL_HOST.

Referenced by a_Cookies_get_query(), and a_Cookies_set().

◆ Cookies_control_check_domain()

static CookieControlAction Cookies_control_check_domain ( const char *  domain)
static

Check the rules for an appropriate action for this domain.

The rules are ordered by domain length, with longest first, so the first match is the most specific.

Definition at line 337 of file cookies.c.

References ccontrol, default_action, dStrAsciiCasecmp(), and num_ccontrol.

◆ Cookies_fopen()

static FILE * Cookies_fopen ( const char *  filename,
char *  init_str 
)
static

Return a file pointer.

If the file doesn't exist, try to create it, with the optional 'init_str' as its content.

Definition at line 80 of file cookies.c.

References dClose(), dStrerror, and MSG.

Variable Documentation

◆ ccontrol

CookieControl* ccontrol = NULL
static

Definition at line 64 of file cookies.c.

◆ default_action

CookieControlAction default_action = COOKIE_DENY
static

Definition at line 67 of file cookies.c.

◆ disabled

bool_t disabled
static

Definition at line 69 of file cookies.c.

◆ num_ccontrol

int num_ccontrol = 0
static

Definition at line 65 of file cookies.c.

◆ num_ccontrol_max

int num_ccontrol_max = 1
static

Definition at line 66 of file cookies.c.