![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Data Structures | |
| struct | N_TIME |
| Timing Structure. More... | |
Macros | |
| #define | N_TIME_HTTP_DATE_LEN 30 |
| buffer size for n_time_http_date(): "Thu, 01 Jan 1970 00:00:00 GMT" + NUL | |
| #define | N_TIME_RFC2822_LEN 32 |
| buffer size for n_time_rfc2822(): "Thu, 01 Jan 1970 00:00:00 +0000" + NUL | |
| #define | N_TIME_RFC3339_LEN 26 |
| buffer size for n_time_rfc3339(): "1970-01-01T00:00:00+00:00" + NUL | |
Functions | |
| time_t | get_msec (N_TIME *timer) |
| Poll any N_TIME HiTimer, returning msec. | |
| time_t | get_sec (N_TIME *timer) |
| Poll any N_TIME HiTimer, returning sec. | |
| time_t | get_usec (N_TIME *timer) |
| Poll any N_TIME HiTimer, returning usec. | |
| int | n_time_http_date (time_t t, char *out, size_t size) |
| format t as an HTTP date (RFC 9110 IMF-fixdate, always GMT) | |
| int | n_time_parse_http_date (const char *s, size_t len, time_t *t) |
| parse an HTTP date in IMF-fixdate form ("Sun, 06 Nov 1994 08:49:37 GMT") | |
| int | n_time_parse_rfc3339 (const char *s, size_t len, time_t *t) |
| parse "YYYY-MM-DD[T| ]HH:MM:SS[Z|+hh:mm|-hh:mm]" | |
| int | n_time_rfc2822 (time_t t, long offset, char *out, size_t size) |
| format t as an RFC 2822 date with a numeric offset, as RSS wants | |
| int | n_time_rfc3339 (time_t t, long offset, char *out, size_t size) |
| format t as RFC 3339 / ISO 8601 with a numeric offset | |
| void | PAUSE (void) |
| for the 'press a key to continue' | |
| int | start_HiTimer (N_TIME *timer) |
| Init or restart from zero any N_TIME HiTimer. | |
| void | u_sleep (unsigned int usec) |
| sleep for the given number of microseconds | |
| struct N_TIME |
Timing Structure.
| Data Fields | ||
|---|---|---|
| struct timeval | currentTime | current time |
| time_t | delta | time since last poll |
| struct timeval | startTime | start time |
| #define N_TIME_HTTP_DATE_LEN 30 |
buffer size for n_time_http_date(): "Thu, 01 Jan 1970 00:00:00 GMT" + NUL
Definition at line 90 of file n_time.h.
Referenced by n_http_response_head(), n_time_http_date(), and test_format().
| #define N_TIME_RFC2822_LEN 32 |
buffer size for n_time_rfc2822(): "Thu, 01 Jan 1970 00:00:00 +0000" + NUL
Definition at line 92 of file n_time.h.
Referenced by n_time_rfc2822(), and test_format().
| #define N_TIME_RFC3339_LEN 26 |
buffer size for n_time_rfc3339(): "1970-01-01T00:00:00+00:00" + NUL
Definition at line 94 of file n_time.h.
Referenced by n_time_rfc3339(), and test_format().
| time_t get_msec | ( | N_TIME * | timer | ) |
Poll any N_TIME HiTimer, returning msec.
Poll any N_TIME HiTimer, returning msec.
| timer | Any N_TIMER *timer you wanna poll |
Definition at line 129 of file n_time.c.
References __n_assert, N_TIME::currentTime, N_TIME::delta, and N_TIME::startTime.
Referenced by main(), and main().
| time_t get_sec | ( | N_TIME * | timer | ) |
Poll any N_TIME HiTimer, returning sec.
Poll any N_TIME HiTimer, returning sec.
| timer | Any N_TIMER *timer you wanna poll |
Definition at line 150 of file n_time.c.
References __n_assert, N_TIME::currentTime, N_TIME::delta, and N_TIME::startTime.
| time_t get_usec | ( | N_TIME * | timer | ) |
Poll any N_TIME HiTimer, returning usec.
Poll any N_TIME HiTimer, returning usec.
| timer | Any N_TIMER *timer you wanna poll |
Definition at line 108 of file n_time.c.
References __n_assert, N_TIME::currentTime, N_TIME::delta, and N_TIME::startTime.
Referenced by _netw_timed_connect(), main(), main(), manage_particle(), n_kafka_polling_thread(), and netw_connect_ex_to().
| int n_time_http_date | ( | time_t | t, |
| char * | out, | ||
| size_t | size ) |
format t as an HTTP date (RFC 9110 IMF-fixdate, always GMT)
For Date, Last-Modified and Expires. Pure calendar arithmetic: no locale, no TZ, no gmtime(), the same result on every platform. Years 1 to 9999.
| t | seconds since the Unix epoch |
| out | destination, at least N_TIME_HTTP_DATE_LEN bytes |
| size | size of out |
| t | seconds since the Unix epoch |
| out | destination, at least N_TIME_HTTP_DATE_LEN bytes |
| size | size of out |
Definition at line 237 of file n_time.c.
References _civil_of(), _month_names, _wday_names, _n_civil::hour, _n_civil::mday, _n_civil::min, _n_civil::mon, N_TIME_HTTP_DATE_LEN, _n_civil::sec, _n_civil::wday_idx, and _n_civil::year.
Referenced by n_http_response_head(), test_format(), and test_parse().
| int n_time_parse_http_date | ( | const char * | s, |
| size_t | len, | ||
| time_t * | t ) |
parse an HTTP date in IMF-fixdate form ("Sun, 06 Nov 1994 08:49:37 GMT")
Strict: exactly that shape, a weekday that matches the date, real calendar values (no Feb 30, no hour 24, no leap second). The obsolete RFC 850 and asctime forms are refused; a caller handling If-Modified-Since then just ignores the header, which is always safe.
| s | the text (may be NULL only when len is 0) |
| len | its length |
| t | receives seconds since the Unix epoch |
parse an HTTP date in IMF-fixdate form ("Sun, 06 Nov 1994 08:49:37 GMT")
| s | the text (may be NULL only when len is 0) |
| len | its length |
| t | receives seconds since the Unix epoch |
Definition at line 313 of file n_time.c.
References _civil_of(), _civil_to_time(), _digits(), _month_names, _wday_names, h(), and _n_civil::wday_idx.
Referenced by parses(), and test_parse().
| int n_time_parse_rfc3339 | ( | const char * | s, |
| size_t | len, | ||
| time_t * | t ) |
parse "YYYY-MM-DD[T| ]HH:MM:SS[Z|+hh:mm|-hh:mm]"
RFC 3339 timestamps, and the SQL "YYYY-MM-DD HH:MM:SS" form; without a zone the time is UTC. No fractional seconds. Calendar values checked.
| s | the text (may be NULL only when len is 0) |
| len | its length |
| t | receives seconds since the Unix epoch |
parse "YYYY-MM-DD[T| ]HH:MM:SS[Z|+hh:mm|-hh:mm]"
| s | the text (may be NULL only when len is 0) |
| len | its length |
| t | receives seconds since the Unix epoch |
Definition at line 340 of file n_time.c.
References _civil_to_time(), _digits(), and h().
Referenced by parses(), and test_parse().
| int n_time_rfc2822 | ( | time_t | t, |
| long | offset, | ||
| char * | out, | ||
| size_t | size ) |
format t as an RFC 2822 date with a numeric offset, as RSS wants
"Thu, 01 Jan 1970 01:00:00 +0100": the local time at offset seconds east of UTC (PHP's date(DATE_RSS) output for that zone).
| t | seconds since the Unix epoch |
| offset | offset from UTC in seconds, a multiple of 60, |offset| < 86400 |
| out | destination, at least N_TIME_RFC2822_LEN bytes |
| size | size of out |
format t as an RFC 2822 date with a numeric offset, as RSS wants
| t | seconds since the Unix epoch |
| offset | offset from UTC in seconds, a multiple of 60, |offset| < 86400 |
| out | destination, at least N_TIME_RFC2822_LEN bytes |
| size | size of out |
Definition at line 254 of file n_time.c.
References _civil_of(), _month_names, _offset_ok(), _wday_names, _n_civil::hour, _n_civil::mday, _n_civil::min, _n_civil::mon, N_TIME_RFC2822_LEN, _n_civil::sec, _n_civil::wday_idx, and _n_civil::year.
Referenced by test_format().
| int n_time_rfc3339 | ( | time_t | t, |
| long | offset, | ||
| char * | out, | ||
| size_t | size ) |
format t as RFC 3339 / ISO 8601 with a numeric offset
"1970-01-01T01:00:00+01:00" (PHP's date('c') for that zone; offset 0 gives "+00:00", not "Z").
| t | seconds since the Unix epoch |
| offset | offset from UTC in seconds, a multiple of 60, |offset| < 86400 |
| out | destination, at least N_TIME_RFC3339_LEN bytes |
| size | size of out |
format t as RFC 3339 / ISO 8601 with a numeric offset
| t | seconds since the Unix epoch |
| offset | offset from UTC in seconds, a multiple of 60, |offset| < 86400 |
| out | destination, at least N_TIME_RFC3339_LEN bytes |
| size | size of out |
Definition at line 272 of file n_time.c.
References _civil_of(), _offset_ok(), _n_civil::hour, _n_civil::mday, _n_civil::min, _n_civil::mon, N_TIME_RFC3339_LEN, _n_civil::sec, and _n_civil::year.
Referenced by test_format(), and test_parse().
| void PAUSE | ( | void | ) |
| int start_HiTimer | ( | N_TIME * | timer | ) |
Init or restart from zero any N_TIME HiTimer.
Init or restart from zero any N_TIME HiTimer.
| timer | Any N_TIMER *timer you wanna start or reset |
Definition at line 86 of file n_time.c.
References __n_assert, N_TIME::delta, and N_TIME::startTime.
Referenced by _netw_timed_connect(), init_particle_system(), main(), main(), main(), n_kafka_polling_thread(), and netw_connect_ex_to().
| void u_sleep | ( | unsigned int | usec | ) |
sleep for the given number of microseconds
sleep for the given number of microseconds
| usec | Number of usec to sleep |
Definition at line 55 of file n_time.c.
Referenced by destroy_threaded_pool(), handle_client(), main(), main(), main(), manage_client(), netw_accept_pool_thread_func(), netw_send_func(), netw_wait_msg(), recv_ssl_data(), run_client(), run_server(), send_ssl_data(), and wait_for_threaded_pool().