NodeC  0.1
Various

Various utility functions. More...

Macros

#define NODEC_KB
 1 KB.
 
#define NODEC_MB
 1 MB.
 
#define NODEC_GB
 1 GB
 

Typedefs

typedef void() nodec_main_fun_t()
 Type of the asynchronous main function.
 

Functions

void nodec_throw (int err)
 Throw an error, either an errno or uv_errno_t. More...
 
void nodec_throw_msg (int err, const char *msg)
 Throw an error, either an errno or uv_errno_t. More...
 
bool nodec_starts_with (const char *s, const char *prefix)
 Does a string start with a prefix? More...
 
bool nodec_starts_withi (const char *s, const char *prefix)
 Does a string start with a prefix? Uses case-insensitive comparison. More...
 
bool nodec_ends_with (const char *s, const char *postfix)
 Does a string end with a postfix? More...
 
bool nodec_ends_withi (const char *s, const char *postfix)
 Does a string end with a postfix? Uses case-insensitive comparison. More...
 
const char * nodec_inet_date_now ()
 Get the current time as a RFC1123 internet date. More...
 
const char * nodec_inet_date (time_t now)
 Format a time as a RFC1123 internet date. More...
 
bool nodec_parse_inet_date (const char *date, time_t *t)
 Parse a RFC1123 internet date. More...
 
uv_errno_t async_main (nodec_main_fun_t *entry)
 Run the passed in function as the main asynchronous function. More...
 

Detailed Description

Various utility functions.

Function Documentation

◆ async_main()

uv_errno_t async_main ( nodec_main_fun_t entry)

Run the passed in function as the main asynchronous function.

This starts the libuv event loop and sets up the asynchronous and exception effect handlers.

Parameters
entryThe main asynchronous entry point.
Returns
A possible error code or 0 on success.

◆ nodec_ends_with()

bool nodec_ends_with ( const char *  s,
const char *  postfix 
)

Does a string end with a postfix?

Parameters
sThe string to analyze, can be NULL, in which case false is returned.
postfixThe postfix to compare, can be NULL, in which case false is returned.
Returns
True if the string ends with postfix.

◆ nodec_ends_withi()

bool nodec_ends_withi ( const char *  s,
const char *  postfix 
)

Does a string end with a postfix? Uses case-insensitive comparison.

Parameters
sThe string to analyze, can be NULL, in which case false is returned.
postfixThe postfix to compare, can be NULL, in which case false is returned.
Returns
True if the string ends with postfix.

◆ nodec_inet_date()

const char* nodec_inet_date ( time_t  now)

Format a time as a RFC1123 internet date.

Caches previous results to increase efficiency.

Parameters
nowThe time to convert.
Returns
The current time in RFC1123 format, for example Thu, 01 Jan 1972 00:00:00 GMT.

◆ nodec_inet_date_now()

const char* nodec_inet_date_now ( )

Get the current time as a RFC1123 internet date.

Caches previous results to increase efficiency.

Returns
The current time in RFC1123 format, for example Thu, 01 Jan 1972 00:00:00 GMT.

◆ nodec_parse_inet_date()

bool nodec_parse_inet_date ( const char *  date,
time_t *  t 
)

Parse a RFC1123 internet date.

Parameters
dateA RFC1123 formatted internet date, for example Thu, 01 Jan 1972 00:00:00 GMT. Can be NULL which is treated as an invalid date.
[out]tSet to the time according to date. If the date was not valid, the UNIX epoch is used.
Returns
True if successful.

◆ nodec_starts_with()

bool nodec_starts_with ( const char *  s,
const char *  prefix 
)

Does a string start with a prefix?

Parameters
sThe string to analyze, can be NULL, in which case false is returned.
prefixThe prefix to compare, can be NULL, in which case false is returned.
Returns
True if the string starts with prefix.

◆ nodec_starts_withi()

bool nodec_starts_withi ( const char *  s,
const char *  prefix 
)

Does a string start with a prefix? Uses case-insensitive comparison.

Parameters
sThe string to analyze, can be NULL, in which case false is returned.
prefixThe prefix to compare, can be NULL, in which case false is returned.
Returns
True if the string starts with prefix.

◆ nodec_throw()

void nodec_throw ( int  err)

Throw an error, either an errno or uv_errno_t.

Parameters
errerror code.

◆ nodec_throw_msg()

void nodec_throw_msg ( int  err,
const char *  msg 
)

Throw an error, either an errno or uv_errno_t.

Parameters
errerror code.
msgcustom message.