Add time functions, simplify API
[libcontrac.git] / include / contrac / utils.h
1 /** \ingroup contrac
2 * @file
3 * @author David Llewellyn-Jones
4 * @version $(VERSION)
5 *
6 * @section LICENSE
7 *
8 *
9 *
10 * @brief
11 * @section DESCRIPTION
12 *
13 *
14 *
15 */
16
17
18 #ifndef __UTILS_H
19 #define __UTILS_H
20
21 // Includes
22
23 #include <time.h>
24
25 // Defines
26
27 #define MAX(a,b) \
28 ({ __typeof__ (a) _a = (a); \
29 __typeof__ (b) _b = (b); \
30 _a > _b ? _a : _b; })
31
32 #define MIN(a,b) \
33 ({ __typeof__ (a) _a = (a); \
34 __typeof__ (b) _b = (b); \
35 _a < _b ? _a : _b; })
36
37 // Structures
38
39 // Function prototypes
40
41 size_t base64_encode_size(size_t binary_input);
42 size_t base64_decode_size(size_t base64_input);
43 void base64_encode_binary_to_base64(unsigned char const *input, size_t input_size, unsigned char *output, size_t *output_size);
44 void base64_decode_base64_to_binary(unsigned char const *input, size_t input_size, unsigned char *output, size_t *output_size);
45
46 uint32_t epoch_to_day_number(time_t epoch);
47 uint8_t epoch_to_time_interval_number(time_t epoch);
48
49 // Function definitions
50
51 #endif // __UTILS_H
52
53
54
55
56