Dillo v3.1.1-119-g140d9ebd
Loading...
Searching...
No Matches
cookies.c File Reference
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include "dlib/dlib.h"
#include "dpip/dpip.h"
Include dependency graph for cookies.c:

Go to the source code of this file.

Macros

#define _MSG(...)
 
#define MSG_INNARDS(prefix, ...)
 
#define MSG(...)   MSG_INNARDS("", __VA_ARGS__)
 
#define MSG_WARN(...)   MSG_INNARDS("** WARNING **: ", __VA_ARGS__)
 
#define MSG_ERR(...)   MSG_INNARDS("** ERROR **: ", __VA_ARGS__)
 

Functions

static char * Dpi_blocking_read (int fd)
 
static void Dpi_close_fd (int fd)
 
static int Dpi_make_socket_fd ()
 
static int Dpi_read_comm_keys (int *port)
 
static int Dpi_check_dpid_ids ()
 
static int Dpi_blocking_write (int fd, const char *msg, int msg_len)
 
static int Dpi_start_dpid (void)
 
static int Dpi_check_dpid (int num_tries)
 
static int Dpi_blocking_start_dpid (void)
 
static int Dpi_get_server_port (const char *server_name)
 
static int Dpi_connect_socket (const char *server_name)
 
char * a_Dpi_send_blocking_cmd (const char *server_name, const char *cmd)
 Send a command to a dpi server, and block until the answer is got.
 
void a_Cookies_set (const char *cookie, const char *host, const char *path, const char *date)
 
char * a_Cookies_get_query (const char *scheme, const char *host, const char *path)
 
static void expect (int lineno, const char *exp_reply, const char *scheme, const char *host, const char *path)
 
static void toomany ()
 
static void maxage ()
 
static void expires_server_ahead ()
 
static void expires_server_behind ()
 
static void expires_extremes ()
 
static void expires_date_formats ()
 
static void path ()
 
int Cookies_rc_check ()
 
int main ()
 

Variables

static uint_t failed = 0
 
static uint_t passed = 0
 
static char SharedKey [32]
 

Macro Definition Documentation

◆ _MSG

#define _MSG (   ...)

Definition at line 38 of file cookies.c.

◆ MSG

#define MSG (   ...)    MSG_INNARDS("", __VA_ARGS__)

Definition at line 46 of file cookies.c.

◆ MSG_ERR

#define MSG_ERR (   ...)    MSG_INNARDS("** ERROR **: ", __VA_ARGS__)

Definition at line 48 of file cookies.c.

◆ MSG_INNARDS

#define MSG_INNARDS (   prefix,
  ... 
)
Value:
printf(prefix __VA_ARGS__); \
fflush (stdout); \
#define D_STMT_START
Definition dlib.h:62
#define D_STMT_END
Definition dlib.h:63

Definition at line 40 of file cookies.c.

◆ MSG_WARN

#define MSG_WARN (   ...)    MSG_INNARDS("** WARNING **: ", __VA_ARGS__)

Definition at line 47 of file cookies.c.

Function Documentation

◆ a_Cookies_get_query()

char * a_Cookies_get_query ( const char *  scheme,
const char *  host,
const char *  path 
)

◆ a_Cookies_set()

void a_Cookies_set ( const char *  cookie,
const char *  host,
const char *  path,
const char *  date 
)

Definition at line 436 of file cookies.c.

References _MSG, a_Dpi_send_blocking_cmd(), a_Dpip_build_cmd(), dFree(), and path().

◆ a_Dpi_send_blocking_cmd()

char * a_Dpi_send_blocking_cmd ( const char *  server_name,
const char *  cmd 
)

Send a command to a dpi server, and block until the answer is got.

Return value: the dpip tag answer as an string, NULL on error.

Definition at line 412 of file cookies.c.

References Dpi_blocking_read(), Dpi_blocking_start_dpid(), Dpi_blocking_write(), Dpi_close_fd(), Dpi_connect_socket(), and MSG_ERR.

◆ Cookies_rc_check()

int Cookies_rc_check ( )

◆ Dpi_blocking_read()

static char * Dpi_blocking_read ( int  fd)
static

◆ Dpi_blocking_start_dpid()

static int Dpi_blocking_start_dpid ( void  )
static

Definition at line 277 of file cookies.c.

References Dpi_check_dpid(), dUsleep(), and MSG.

Referenced by a_Dpi_send_blocking_cmd().

◆ Dpi_blocking_write()

static int Dpi_blocking_write ( int  fd,
const char *  msg,
int  msg_len 
)
static

Definition at line 167 of file cookies.c.

References dStrerror, and MSG_ERR.

Referenced by a_Dpi_send_blocking_cmd(), Dpi_connect_socket(), Dpi_get_server_port(), and Dpi_start_dpid().

◆ Dpi_check_dpid()

static int Dpi_check_dpid ( int  num_tries)
static

Definition at line 243 of file cookies.c.

References _MSG, Dpi_check_dpid_ids(), and Dpi_start_dpid().

Referenced by Dpi_blocking_start_dpid().

◆ Dpi_check_dpid_ids()

static int Dpi_check_dpid_ids ( void  )
static

Definition at line 142 of file cookies.c.

References Dpi_close_fd(), Dpi_make_socket_fd(), Dpi_read_comm_keys(), dStrerror, and MSG.

Referenced by Dpi_check_dpid().

◆ Dpi_close_fd()

static void Dpi_close_fd ( int  fd)
static

◆ Dpi_connect_socket()

static int Dpi_connect_socket ( const char *  server_name)
static

◆ Dpi_get_server_port()

static int Dpi_get_server_port ( const char *  server_name)
static

◆ Dpi_make_socket_fd()

static int Dpi_make_socket_fd ( void  )
static

Definition at line 102 of file cookies.c.

Referenced by Dpi_check_dpid_ids(), Dpi_connect_socket(), and Dpi_get_server_port().

◆ Dpi_read_comm_keys()

static int Dpi_read_comm_keys ( int *  port)
static

Definition at line 116 of file cookies.c.

References dFree(), dGethomedir(), dGetline(), dStrconcat(), dStrerror, MSG_ERR, and SharedKey.

Referenced by Dpi_check_dpid_ids(), and Dpi_get_server_port().

◆ Dpi_start_dpid()

static int Dpi_start_dpid ( void  )
static

◆ expect()

static void expect ( int  lineno,
const char *  exp_reply,
const char *  scheme,
const char *  host,
const char *  path 
)
static

◆ expires_date_formats()

static void expires_date_formats ( )
static

Definition at line 771 of file cookies.c.

References a_Cookies_set(), and expect().

Referenced by main().

◆ expires_extremes()

static void expires_extremes ( )
static

Definition at line 686 of file cookies.c.

References a_Cookies_set(), dFree(), dStrdup(), and expect().

Referenced by main().

◆ expires_server_ahead()

static void expires_server_ahead ( )
static

Definition at line 592 of file cookies.c.

References a_Cookies_set(), dFree(), dStrconcat(), dStrdup(), and expect().

Referenced by main().

◆ expires_server_behind()

static void expires_server_behind ( )
static

Definition at line 644 of file cookies.c.

References a_Cookies_set(), dFree(), dStrconcat(), dStrdup(), and expect().

Referenced by main().

◆ main()

◆ maxage()

static void maxage ( )
static

Definition at line 534 of file cookies.c.

References a_Cookies_set(), dFree(), dStrdup(), and expect().

Referenced by main().

◆ path()

◆ toomany()

static void toomany ( )
static

Definition at line 495 of file cookies.c.

References a_Cookies_set(), and expect().

Referenced by main().

Variable Documentation

◆ failed

uint_t failed = 0
static

Definition at line 54 of file cookies.c.

Referenced by expect(), main(), Tls_connect(), and Tls_handshake().

◆ passed

uint_t passed = 0
static

Definition at line 55 of file cookies.c.

Referenced by expect(), and main().

◆ SharedKey

char SharedKey[32]
static

Definition at line 57 of file cookies.c.

Referenced by Dpi_connect_socket(), and Dpi_read_comm_keys().