supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla-common
tools.h
1
/*
2
Copyright (C) AC SOFTWARE SP. Z O.O.
3
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License
6
as published by the Free Software Foundation; either version 2
7
of the License, or (at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
*/
18
19
#ifndef ARDUINO
20
21
#ifndef suplatools_H_
22
#define suplatools_H_
23
24
#include <stdlib.h>
25
26
#include "proto.h"
27
28
#ifdef __cplusplus
29
extern
"C"
{
30
#endif
31
32
typedef
struct
{
33
double
h;
34
double
s;
35
double
v;
36
}
_color_hsv_t
;
37
38
#define BCRYPT_HASH_MAXSIZE 65
39
40
extern
unsigned
char
st_app_terminate;
41
42
unsigned
char
st_file_exists(
const
char
*fp);
43
void
st_hook_signals(
void
);
44
void
st_hook_critical_signals(
void
);
45
char
st_try_fork(
void
);
46
char
st_set_ug_id(
const
char
*username,
int
uid,
int
gid);
47
char
st_setpidfile(
char
*pidfile_path);
48
void
st_delpidfile(
char
*pidfile_path);
49
void
st_mainloop_init();
50
void
st_mainloop_wait(
int
usec);
51
void
st_mainloop_free();
52
53
void
st_guid2hex(
char
GUIDHEX[SUPLA_GUID_HEXSIZE],
54
const
char
GUID[SUPLA_GUID_SIZE]);
55
void
st_authkey2hex(
char
AuthKeyHEX[SUPLA_AUTHKEY_HEXSIZE],
56
const
char
AuthKey[SUPLA_AUTHKEY_SIZE]);
57
58
char
*st_str2hex(
char
*buffer,
const
char
*str,
size_t
maxlen);
59
char
*st_bin2hex(
char
*buffer,
const
char
*src,
size_t
len);
60
61
char
st_read_randkey_from_file(
char
*file,
char
*KEY,
int
size,
char
create);
62
char
st_read_guid_from_file(
char
*file,
char
*GUID,
char
create);
63
char
st_read_authkey_from_file(
char
*file,
char
*AuthKey,
char
create);
64
65
time_t st_get_utc_time(
void
);
66
67
char
*st_get_zulu_time(
char
buffer[64]);
68
char
*st_get_datetime_str(
char
buffer[64]);
69
70
_color_hsv_t
st_rgb2hsv(
int
rgb);
71
int
st_hsv2rgb(
_color_hsv_t
in);
72
int
st_hue2rgb(
double
hue);
73
74
void
st_random_alpha_string(
char
*buffer,
int
buffer_size);
75
void
st_uuid_v4(
char
buffer[37]);
76
77
#ifdef __BCRYPT
78
79
char
st_bcrypt_gensalt(
char
*salt,
int
salt_buffer_size,
char
rounds);
80
char
st_bcrypt_hash(
const
char
*str,
const
char
*salt,
char
*hash,
81
int
hash_buffer_size);
82
char
st_bcrypt_crypt(
char
*str,
char
*hash,
int
hash_buffer_size,
char
rounds);
83
char
st_bcrypt_check(
const
char
*str,
char
*hash,
int
hash_len);
84
char
*st_get_authkey_hash_hex(
const
char
AuthKey[SUPLA_AUTHKEY_SIZE]);
85
int
format_decimal_trunc(
double
x,
int
precision,
int
scale,
char
*out,
86
size_t
outsz);
87
#endif
88
89
unsigned
_supla_int_t st_crc32_checksum(
const
unsigned
char
*data,
90
size_t
length);
91
92
#ifdef __OPENSSL_TOOLS
93
char
*st_openssl_base64_encode(
const
char
*src,
int
src_len);
94
char
*st_openssl_base64_decode(
const
char
*src,
int
src_len,
int
*dst_len);
95
#endif
96
97
#ifdef __cplusplus
98
}
99
#endif
100
101
#endif
/* suplatools_H_ */
102
#endif
/* !ARDUINO */
_color_hsv_t
Definition
tools.h:32
Generated by
1.17.0