1
1
/* *
2
- *
2
+ *
3
3
* helpers.cpp: InfluxDB Client util functions
4
- *
4
+ *
5
5
* MIT License
6
- *
6
+ *
7
7
* Copyright (c) 2020 InfluxData
8
- *
8
+ *
9
9
* Permission is hereby granted, free of charge, to any person obtaining a copy
10
10
* of this software and associated documentation files (the "Software"), to deal
11
11
* in the Software without restriction, including without limitation the rights
12
12
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
13
* copies of the Software, and to permit persons to whom the Software is
14
14
* furnished to do so, subject to the following conditions:
15
- *
15
+ *
16
16
* The above copyright notice and this permission notice shall be included in all
17
17
* copies or substantial portions of the Software.
18
- *
18
+ *
19
19
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
20
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
21
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
28
29
29
void timeSync (const char *tzInfo, const char * ntpServer1, const char * ntpServer2, const char * ntpServer3) {
30
30
// Accurate time is necessary for certificate validion
31
-
31
+
32
32
configTzTime (tzInfo,ntpServer1, ntpServer2, ntpServer3);
33
33
34
34
// Wait till time is synced
@@ -50,16 +50,16 @@ void timeSync(const char *tzInfo, const char* ntpServer1, const char* ntpServer2
50
50
unsigned long long getTimeStamp (struct timeval *tv, int secFracDigits) {
51
51
unsigned long long tsVal = 0 ;
52
52
switch (secFracDigits) {
53
- case 0 :
53
+ case 0 :
54
54
tsVal = tv->tv_sec ;
55
55
break ;
56
- case 6 :
56
+ case 6 :
57
57
tsVal = tv->tv_sec * 1000000LL + tv->tv_usec ;
58
58
break ;
59
59
case 9 :
60
60
tsVal = tv->tv_sec * 1000000000LL + tv->tv_usec * 1000LL ;
61
61
break ;
62
- case 3 :
62
+ case 3 :
63
63
default :
64
64
tsVal = tv->tv_sec * 1000LL + tv->tv_usec / 1000LL ;
65
65
break ;
@@ -77,7 +77,7 @@ String timeStampToString(unsigned long long timestamp) {
77
77
String escapeKey (String key, bool escapeEqual) {
78
78
String ret;
79
79
ret.reserve (key.length ()+5 ); // 5 is estimate of chars needs to escape,
80
-
80
+
81
81
for (char c: key)
82
82
{
83
83
switch (c)
@@ -126,18 +126,18 @@ static char hex_digit(char c) {
126
126
return " 0123456789ABCDEF" [c & 0x0F ];
127
127
}
128
128
129
- String urlEncode (const char * src) {
129
+ String urlEncode (const char * src) {
130
130
int n=0 ;
131
131
char c,*s = (char *)src;
132
132
while (c = *s++) {
133
133
if (strchr (invalidChars, c)) {
134
134
n++;
135
- }
135
+ }
136
136
}
137
137
String ret;
138
138
ret.reserve (strlen (src)+2 *n+1 );
139
139
s = (char *)src;
140
- while (c = *s++) {
140
+ while (( c = *s++)) {
141
141
if (strchr (invalidChars,c)) {
142
142
ret += ' %' ;
143
143
ret += hex_digit (c >> 4 );
0 commit comments