libre  0.5.0
Macros | Functions
re_sys.h File Reference

Interface to system module. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ARCH   "?"
 Architecture.
#define OS   "?"
 Operating System.

Functions

int sys_rel_get (uint32_t *rel, uint32_t *maj, uint32_t *min, uint32_t *patch)
 Get system release version.
int sys_kernel_get (struct re_printf *pf, void *unused)
 Get kernel name and version.
int sys_build_get (struct re_printf *pf, void *unused)
 Get build info.
const char * sys_arch_get (void)
 Get architecture.
const char * sys_os_get (void)
 Get name of Operating System.
const char * sys_libre_version_get (void)
 Get libre version.
const char * sys_username (void)
 Return the username (login name) for the current user.
int sys_coredump_set (bool enable)
 Enable or disable coredump.
int sys_daemon (void)
 Daemonize process.
void sys_usleep (unsigned int us)
 Blocking sleep for [us] number of microseconds.
uint16_t sys_htols (uint16_t v)
 Convert a 16-bit value from host order to little endian.
uint32_t sys_htoll (uint32_t v)
 Convert a 32-bit value from host order to little endian.
uint16_t sys_ltohs (uint16_t v)
 Convert a 16-bit value from little endian to host order.
uint32_t sys_ltohl (uint32_t v)
 Convert a 32-bit value from little endian to host order.
uint64_t sys_htonll (uint64_t v)
 Convert a 64-bit value from host to network byte-order.
uint64_t sys_ntohll (uint64_t v)
 Convert a 64-bit value from network to host byte-order.
void rand_init (void)
 Initialise random number generator.
uint16_t rand_u16 (void)
 Generate an unsigned 16-bit random value.
uint32_t rand_u32 (void)
 Generate an unsigned 32-bit random value.
uint64_t rand_u64 (void)
 Generate an unsigned 64-bit random value.
char rand_char (void)
 Generate a random printable character.
void rand_str (char *str, size_t size)
 Generate a string of random characters.
void rand_bytes (uint8_t *p, size_t size)
 Generate a set of random bytes.
int fs_mkdir (const char *path, uint16_t mode)
 Create a directory with full path.
int fs_gethome (char *path, size_t sz)
 Get the home directory for the current user.

Detailed Description

Interface to system module.

Copyright (C) 2010 Creytiv.com

Definition in file re_sys.h.

Function Documentation

int fs_gethome ( char *  path,
size_t  sz 
)

Get the home directory for the current user.

Parameters
pathString to write home directory
szSize of path string
Returns
0 if success, otherwise errorcode

Definition at line 66 of file fs.c.

References NULL, str_ncpy(), and sys_username().

int fs_mkdir ( const char *  path,
uint16_t  mode 
)

Create a directory with full path.

Parameters
pathDirectory path
modeAccess permissions
Returns
0 if success, otherwise errorcode

Definition at line 38 of file fs.c.

void rand_bytes ( uint8_t *  p,
size_t  size 
)

Generate a set of random bytes.

Parameters
pPointer to buffer
sizeSize of buffer

Definition at line 158 of file rand.c.

References DEBUG_WARNING, and rand_u32().

char rand_char ( void  )

Generate a random printable character.

Returns
Random printable character

Definition at line 118 of file rand.c.

References RAND_CHECK, and rand_u16().

Referenced by rand_str().

void rand_str ( char *  str,
size_t  size 
)

Generate a string of random characters.

Parameters
strPointer to string
sizeSize of string

Definition at line 138 of file rand.c.

References rand_char(), and RAND_CHECK.

Referenced by ice_alloc().

uint16_t rand_u16 ( void  )

Generate an unsigned 16-bit random value.

Returns
16-bit random value

Definition at line 61 of file rand.c.

References RAND_CHECK, and rand_u32().

Referenced by rand_char(), rtp_alloc(), sip_dialog_accept(), and sip_dialog_alloc().

uint32_t rand_u32 ( void  )

Generate an unsigned 32-bit random value.

Returns
32-bit random value

Definition at line 75 of file rand.c.

References DEBUG_WARNING, and RAND_CHECK.

Referenced by rand_bytes(), rand_u16(), rand_u64(), rtp_alloc(), sdp_session_alloc(), sip_dialog_accept(), stun_indication(), stun_request(), and tls_set_selfsigned().

uint64_t rand_u64 ( void  )

Generate an unsigned 64-bit random value.

Returns
64-bit random value

Definition at line 105 of file rand.c.

References RAND_CHECK, and rand_u32().

Referenced by http_auth_print_challenge(), ice_alloc(), sip_dialog_alloc(), and sip_msg_decode().

const char* sys_arch_get ( void  )

Get architecture.

Returns
Architecture string

Definition at line 147 of file sys.c.

References ARCH.

int sys_build_get ( struct re_printf pf,
void *  unused 
)

Get build info.

Parameters
pfPrint function for output
unusedUnused parameter
Returns
0 if success, otherwise errorcode

Definition at line 120 of file sys.c.

References re_hprintf().

int sys_coredump_set ( bool  enable)

Enable or disable coredump.

Parameters
enabletrue to enable, false to disable coredump
Returns
0 if success, otherwise errorcode

Definition at line 220 of file sys.c.

int sys_daemon ( void  )

Daemonize process.

Returns
0 if success, otherwise errorcode

Definition at line 24 of file daemon.c.

References NULL.

uint32_t sys_htoll ( uint32_t  v)

Convert a 32-bit value from host order to little endian.

Parameters
v32-bit in host order
Returns
32-bit little endian value

Definition at line 42 of file endian.c.

uint16_t sys_htols ( uint16_t  v)

Convert a 16-bit value from host order to little endian.

Parameters
v16-bit in host order
Returns
16-bit little endian value

Definition at line 23 of file endian.c.

uint64_t sys_htonll ( uint64_t  v)

Convert a 64-bit value from host to network byte-order.

Parameters
v64-bit host byte-order value
Returns
64-bit value in network byte-order

Definition at line 103 of file endian.c.

int sys_kernel_get ( struct re_printf pf,
void *  unused 
)

Get kernel name and version.

Parameters
pfPrint function for output
unusedUnused parameter
Returns
0 if success, otherwise errorcode

Definition at line 84 of file sys.c.

References re_hprintf().

const char* sys_libre_version_get ( void  )

Get libre version.

Returns
libre version string

Definition at line 177 of file sys.c.

uint32_t sys_ltohl ( uint32_t  v)

Convert a 32-bit value from little endian to host order.

Parameters
v32-bit little endian value
Returns
32-bit value in host order

Definition at line 82 of file endian.c.

uint16_t sys_ltohs ( uint16_t  v)

Convert a 16-bit value from little endian to host order.

Parameters
v16-bit little endian value
Returns
16-bit value in host order

Definition at line 63 of file endian.c.

uint64_t sys_ntohll ( uint64_t  v)

Convert a 64-bit value from network to host byte-order.

Parameters
v64-bit network byte-order value
Returns
64-bit value in host byte-order

Definition at line 128 of file endian.c.

const char* sys_os_get ( void  )

Get name of Operating System.

Returns
Operating System string

Definition at line 162 of file sys.c.

References OS.

int sys_rel_get ( uint32_t *  rel,
uint32_t *  maj,
uint32_t *  min,
uint32_t *  patch 
)

Get system release version.

Parameters
relBinary encoded release
majMajor version number
minMinor version number
patchPatch number
Returns
0 if success, otherwise errorcode

Definition at line 35 of file sys.c.

References NULL, pl::p, pl_u32(), and re_regex().

Referenced by epoll_check().

const char* sys_username ( void  )

Return the username (login name) for the current user.

Returns
Username or NULL if not available

Definition at line 192 of file sys.c.

References NULL.

Referenced by fs_gethome().

void sys_usleep ( unsigned int  us)

Blocking sleep for [us] number of microseconds.

Parameters
usNumber of microseconds to sleep

Definition at line 26 of file sleep.c.

References NULL.