blob: 598e35c2f1368cec0ba362fd65859aae8c66bf52 [file] [log] [blame]
James Kuszmaul82f6c042021-01-17 11:30:16 -08001/**
2 * @file re_sys.h Interface to system module
3 *
4 * Copyright (C) 2010 Creytiv.com
5 */
6
7
8#ifndef VERSION
9#define VERSION "?"
10#endif
11
12/**
13 * @def ARCH
14 *
15 * Architecture
16 */
17#ifndef ARCH
18#define ARCH "?"
19#endif
20
21/**
22 * @def OS
23 *
24 * Operating System
25 */
26#ifndef OS
27#ifdef WIN32
28#define OS "win32"
29#else
30#define OS "?"
31#endif
32#endif
33
34struct re_printf;
35int sys_rel_get(uint32_t *rel, uint32_t *maj, uint32_t *min,
36 uint32_t *patch);
37int sys_kernel_get(struct re_printf *pf, void *unused);
38int sys_build_get(struct re_printf *pf, void *unused);
39const char *sys_arch_get(void);
40const char *sys_os_get(void);
41const char *sys_libre_version_get(void);
42const char *sys_username(void);
43int sys_coredump_set(bool enable);
44int sys_daemon(void);
45void sys_usleep(unsigned int us);
46
47static inline void sys_msleep(unsigned int ms)
48{
49 sys_usleep(ms * 1000);
50}
51
52
53uint16_t sys_htols(uint16_t v);
54uint32_t sys_htoll(uint32_t v);
55uint16_t sys_ltohs(uint16_t v);
56uint32_t sys_ltohl(uint32_t v);
57uint64_t sys_htonll(uint64_t v);
58uint64_t sys_ntohll(uint64_t v);
59
60
61/* Random */
62void rand_init(void);
63uint16_t rand_u16(void);
64uint32_t rand_u32(void);
65uint64_t rand_u64(void);
66char rand_char(void);
67void rand_str(char *str, size_t size);
68void rand_bytes(uint8_t *p, size_t size);
69
70
71/* File-System */
72int fs_mkdir(const char *path, uint16_t mode);
73int fs_gethome(char *path, size_t sz);