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

Go to the source code of this file.

Data Structures

struct  date_vector
 a timestamp and what PHP prints for it More...

Functions

static void expect_true (const char *what, int ok)
 count a failed check
int main (int argc, char **argv)
 run the checks
static int parses (int http, const char *s, int ok, long long want)
 parse s with the given parser and compare with want (or expect failure)
static int process_args (int argc, char **argv)
 read -V
static void test_format (void)
 formatting, compared with PHP's output
static void test_parse (void)
 parsing

Variables

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

Data Structure Documentation

◆ date_vector

struct date_vector

a timestamp and what PHP prints for it

Examples
ex_time_formats.c.

Definition at line 73 of file ex_time_formats.c.

Collaboration diagram for date_vector:
Data Fields
const char * c_paris
const char * c_utc gmdate('c')
const char * http gmdate('D, d M Y H:i:s') .

' GMT'

long paris Europe/Paris offset at t, seconds.
const char * rss_paris
const char * rss_utc gmdate(DATE_RSS)
long long t

Function Documentation

◆ expect_true()

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

count a failed check

Parameters
whatthe check
okits result

Definition at line 46 of file ex_time_formats.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 191 of file ex_time_formats.c.

References failures, LOG_ERR, log_level, LOG_NOTICE, n_log, process_args(), set_log_level(), test_format(), and test_parse().

Here is the call graph for this function:

◆ parses()

int parses ( int http,
const char * s,
int ok,
long long want )
static

parse s with the given parser and compare with want (or expect failure)

Parameters
httpnon-zero: HTTP date parser, else RFC 3339
sthe text
okexpected success
wantexpected time when ok
Returns
non-zero when the outcome is the expected one
Examples
ex_time_formats.c.

Definition at line 131 of file ex_time_formats.c.

References n_time_parse_http_date(), and n_time_parse_rfc3339().

Referenced by test_parse().

Here is the call graph for this function:
Here is the caller 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 59 of file ex_time_formats.c.

References log_level.

◆ test_format()

void test_format ( void )
static

formatting, compared with PHP's output

Examples
ex_time_formats.c.

Definition at line 84 of file ex_time_formats.c.

References expect_true(), n_time_http_date(), N_TIME_HTTP_DATE_LEN, n_time_rfc2822(), N_TIME_RFC2822_LEN, n_time_rfc3339(), and N_TIME_RFC3339_LEN.

Referenced by main().

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

◆ test_parse()

void test_parse ( void )
static

parsing

Definition at line 140 of file ex_time_formats.c.

References expect_true(), failures, LOG_ERR, n_log, n_time_http_date(), n_time_parse_http_date(), n_time_parse_rfc3339(), n_time_rfc3339(), and parses().

Here is the call graph for this function:

Variable Documentation

◆ failures

int failures = 0
static

failed checks

Definition at line 41 of file ex_time_formats.c.

◆ log_level

int log_level = 3
static

log level from -V

Definition at line 39 of file ex_time_formats.c.