Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_http_cookie.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "nilorea/n_common.h"
#include "nilorea/n_http_cookie.h"
#include "nilorea/n_log.h"
#include "nilorea/n_str.h"
Include dependency graph for ex_http_cookie.c:

Go to the source code of this file.

Functions

static int builds (const N_HTTP_SET_COOKIE *c, const char *want)
 build one Set-Cookie and compare
static int cookie_is (const char *header, const char *name, const char *want)
 the cookie name in header has exactly the value want (NULL: absent)
static void expect_true (const char *what, int ok)
 count a failed check
int main (int argc, char **argv)
 run the checks
static int process_args (int argc, char **argv)
 read -V
static void test_build (void)
 building Set-Cookie values
static void test_read (void)
 reading a Cookie header

Variables

static int failures = 0
 failed checks
static int log_level = 3
 log level from -V

Function Documentation

◆ builds()

int builds ( const N_HTTP_SET_COOKIE * c,
const char * want )
static

build one Set-Cookie and compare

Parameters
cthe cookie
wantexpected header value, or NULL when building must fail
Returns
non-zero when the outcome is the expected one
Examples
ex_http_cookie.c.

Definition at line 112 of file ex_http_cookie.c.

References N_STR::data, free_nstr, LOG_ERR, n_http_set_cookie_build(), and n_log.

Referenced by test_build().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cookie_is()

int cookie_is ( const char * header,
const char * name,
const char * want )
static

the cookie name in header has exactly the value want (NULL: absent)

Parameters
headerCookie header value
namecookie name
wantexpected value or NULL
Returns
non-zero when it matches
Examples
ex_http_cookie.c.

Definition at line 79 of file ex_http_cookie.c.

References n_http_cookie_get().

Referenced by test_read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expect_true()

void expect_true ( const char * what,
int ok )
static

count a failed check

Parameters
whatthe check
okits result

Definition at line 48 of file ex_http_cookie.c.

References failures, LOG_ERR, LOG_INFO, and n_log.

◆ main()

int main ( int argc,
char ** argv )

run the checks

Parameters
argcargument count
argvarguments
Returns
0 when every check passes

Definition at line 230 of file ex_http_cookie.c.

References failures, LOG_ERR, log_level, LOG_NOTICE, n_log, process_args(), set_log_level(), test_build(), and test_read().

Here is the call graph for this function:

◆ process_args()

int process_args ( int argc,
char ** argv )
static

read -V

Parameters
argcargument count
argvarguments
Returns
0, or -1 on a bad argument

Definition at line 61 of file ex_http_cookie.c.

References log_level.

◆ test_build()

◆ test_read()

void test_read ( void )
static

reading a Cookie header

Examples
ex_http_cookie.c.

Definition at line 88 of file ex_http_cookie.c.

References cookie_is(), expect_true(), h(), n_http_cookie_count(), and n_http_cookie_get().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ failures

int failures = 0
static

failed checks

Definition at line 43 of file ex_http_cookie.c.

◆ log_level

int log_level = 3
static

log level from -V

Definition at line 41 of file ex_http_cookie.c.