Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_cookies.c File Reference

Domain-aware HTTP cookie jar: Set-Cookie parsing and Cookie header building. More...

#include "nilorea/n_cookies.h"
#include "nilorea/n_common.h"
#include "nilorea/n_log.h"
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <time.h>
+ Include dependency graph for n_cookies.c:

Go to the source code of this file.

Functions

static int n_cookie_domain_matches (const char *cookie_domain, const char *request_domain)
 
static void n_cookie_free (void *ptr)
 
static int n_cookie_path_matches (const char *cookie_path, const char *request_path)
 
void n_cookiejar_add_from_header (N_COOKIE_JAR *jar, const char *set_cookie_value, const char *request_domain)
 parse one Set-Cookie value (without the "Set-Cookie:" name) and store it; request_domain/path supply the defaults
 
N_STRn_cookiejar_build_header (N_COOKIE_JAR *jar, const char *domain, const char *path, int is_secure)
 build a "name=value; name2=value2" Cookie header value for a request (domain/path/secure/expiry matched); free with free_nstr.
 
void n_cookiejar_clear (N_COOKIE_JAR *jar)
 drop every stored cookie
 
size_t n_cookiejar_count (N_COOKIE_JAR *jar)
 number of cookies currently stored
 
void n_cookiejar_free (N_COOKIE_JAR **jar)
 free a cookie jar and all its cookies, then NULL the pointer
 
N_COOKIE_JARn_cookiejar_new (void)
 create an empty cookie jar; free with n_cookiejar_free.
 

Detailed Description

Domain-aware HTTP cookie jar: Set-Cookie parsing and Cookie header building.

Author
Castagnier Mickael
Version
1.0

Definition in file n_cookies.c.

Function Documentation

◆ n_cookie_domain_matches()

static int n_cookie_domain_matches ( const char *  cookie_domain,
const char *  request_domain 
)
static

Definition at line 73 of file n_cookies.c.

Referenced by n_cookiejar_build_header().

+ Here is the caller graph for this function:

◆ n_cookie_free()

static void n_cookie_free ( void *  ptr)
static

Definition at line 38 of file n_cookies.c.

References N_COOKIE::domain, FreeNoLog, N_COOKIE::name, N_COOKIE::path, and N_COOKIE::value.

Referenced by n_cookiejar_add_from_header(), and n_cookiejar_clear().

+ Here is the caller graph for this function:

◆ n_cookie_path_matches()

static int n_cookie_path_matches ( const char *  cookie_path,
const char *  request_path 
)
static

Definition at line 91 of file n_cookies.c.

Referenced by n_cookiejar_build_header().

+ Here is the caller graph for this function: