Skip to content

Commit c1ee368

Browse files
committed
cleanup: trim trailling whitespaces
Signed-off-by: Rafael Silva <perigoso@riseup.net>
1 parent f69ce1e commit c1ee368

14 files changed

+564
-564
lines changed

examples/bearssl_publisher.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ int testCerts(br_x509_trust_anchor *anch);
2424

2525
/**
2626
* @brief The function that would be called whenever a PUBLISH is received.
27-
*
28-
* @note This function is not used in this example.
27+
*
28+
* @note This function is not used in this example.
2929
*/
3030
static void publish_callback(void** unused, struct mqtt_response_publish *published);
3131

3232
/**
33-
* @brief Safely closes the socket in \p ctx before \c exit.
33+
* @brief Safely closes the socket in \p ctx before \c exit.
3434
*/
3535
static void exit_example(int status, bearssl_context *ctx);
3636

3737
/* The next five functions decode a certificate into BearSSL format */
3838

3939
/**
4040
* @brief Callback function to accumulate data in a buffer
41-
*/
41+
*/
4242
static void vblob_append(void *cc, const void *data, size_t len);
4343

4444
/**
@@ -54,14 +54,14 @@ static int certificate_to_trust_anchor(br_x509_certificate *xc, br_x509_trust_an
5454
/**
5555
* @brief Generates trust anchors for BearSSL from the contents of \p ca_file and stores them
5656
* in the \p anchoOut array (based on code in BearSSL tools)
57-
*/
57+
*/
5858
static size_t get_trusted_anchors_from_file(const char *ca_file, br_x509_trust_anchor **anchOut);
5959
/**
6060
* @brief Generates trust anchors for BearSSL from the string \p ca and stores them
6161
* in the \p anchOut array (based on code in BearSSL tools)
62-
*
62+
*
6363
* @returns The number of trust anchors generated
64-
*/
64+
*/
6565
static size_t get_trusted_anchors(const unsigned char *ca, size_t ca_len, br_x509_trust_anchor **anchOut);
6666

6767
// Global to return Ctrl-C event
@@ -76,9 +76,9 @@ void signalHandler(int signum) {
7676
}
7777

7878
/**
79-
* A simple program to that publishes the current time until Ctrl-C is pressed.
79+
* A simple program to that publishes the current time until Ctrl-C is pressed.
8080
*/
81-
int main(int argc, const char *argv[])
81+
int main(int argc, const char *argv[])
8282
{
8383
const char* addr;
8484
const char* port;
@@ -126,20 +126,20 @@ int main(int argc, const char *argv[])
126126

127127
/* generate BearSSL trusted anchors - specifically kept out of open_nb_socket since it needs to malloc */
128128

129-
/*
130-
Generate BearSSL trusted anchors
129+
/*
130+
Generate BearSSL trusted anchors
131131
132-
This code converts the certificate into a format that is readable by the BearSSL library. Sadly there isn't
132+
This code converts the certificate into a format that is readable by the BearSSL library. Sadly there isn't
133133
a way to accomplish this without the use of malloc thus I specifically kept this code out of open_nb_socket.
134134
The author of the bearSSL library offers two options:
135135
136-
1) Do the conversion of the certificate in your code. There are examples of how to do this. The benefit of
136+
1) Do the conversion of the certificate in your code. There are examples of how to do this. The benefit of
137137
this is that you can run the same code against different servers by providing the appropriate trusted root
138138
pem file. The function get_trusted_anchors does exactly this.
139139
140140
2) Use the tool provided with BearSSL to generate the C code that will initialize the trusted anchor structures.
141-
Essentially it simply generates initialized C structures that you can copy into your code. You will not need
142-
to use malloc but you will lose some flexibility. For information on the tool see
141+
Essentially it simply generates initialized C structures that you can copy into your code. You will not need
142+
to use malloc but you will lose some flexibility. For information on the tool see
143143
this page: https://www.bearssl.org/api1.html
144144
*/
145145
ctx.ta_count = get_trusted_anchors_from_file(ca_file, &ctx.anchOut);
@@ -196,7 +196,7 @@ int main(int argc, const char *argv[])
196196
exit_example(EXIT_FAILURE, &ctx);
197197
}
198198
close_socket(&ctx);
199-
199+
200200
if (0 != open_nb_socket(&ctx, addr, port, bearssl_iobuf, sizeof(bearssl_iobuf)))
201201
{
202202
fprintf(stderr, "Unable to open socket: %d\n", errno);
@@ -249,7 +249,7 @@ int main(int argc, const char *argv[])
249249
return 4;
250250
}
251251
usleep(100000U);
252-
}
252+
}
253253

254254
/* disconnect */
255255
printf("\n%s disconnecting from %s\n", argv[0], addr);
@@ -266,7 +266,7 @@ int main(int argc, const char *argv[])
266266

267267
sleep(1);
268268

269-
/* exit */
269+
/* exit */
270270
exit_example(EXIT_SUCCESS, &ctx);
271271
}
272272

@@ -276,7 +276,7 @@ static void exit_example(int status, bearssl_context *ctx)
276276
exit(status);
277277
}
278278

279-
static void publish_callback(void** unused, struct mqtt_response_publish *published)
279+
static void publish_callback(void** unused, struct mqtt_response_publish *published)
280280
{
281281
static const char *prelim = "Received publish('";
282282
/* note that published->topic_name is NOT null-terminated (here we'll change it to a c-string) */
@@ -302,7 +302,7 @@ static void vblob_append(void *cc, const void *data, size_t len)
302302
static void free_ta_contents(br_x509_trust_anchor *ta)
303303
{
304304
free(ta->dn.data);
305-
switch (ta->pkey.key_type)
305+
switch (ta->pkey.key_type)
306306
{
307307
case BR_KEYTYPE_RSA:
308308
free(ta->pkey.key.rsa.n);
@@ -342,7 +342,7 @@ static int certificate_to_trust_anchor(br_x509_certificate *xc, br_x509_trust_an
342342
ta->dn.len = vdn.data_length;
343343
ta->flags = 0;
344344

345-
if (br_x509_decoder_isCA(&dc))
345+
if (br_x509_decoder_isCA(&dc))
346346
{
347347
ta->flags |= BR_X509_TA_CA;
348348
}
@@ -403,7 +403,7 @@ static size_t get_trusted_anchors_from_file(const char *ca_file, br_x509_trust_a
403403

404404
if (certs != NULL) {
405405
size_t read = fread(certs, 1, fsize, f);
406-
406+
407407
fclose(f);
408408

409409
if (read == fsize) {

examples/bio_publisher.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
/**
33
* @file
4-
* A simple program to that publishes the current time whenever ENTER is pressed.
4+
* A simple program to that publishes the current time whenever ENTER is pressed.
55
*/
66
#include <unistd.h>
77
#include <stdlib.h>
@@ -14,30 +14,30 @@
1414

1515
/**
1616
* @brief The function that would be called whenever a PUBLISH is received.
17-
*
18-
* @note This function is not used in this example.
17+
*
18+
* @note This function is not used in this example.
1919
*/
2020
void publish_callback(void** unused, struct mqtt_response_publish *published);
2121

2222
/**
23-
* @brief The client's refresher. This function triggers back-end routines to
23+
* @brief The client's refresher. This function triggers back-end routines to
2424
* handle ingress/egress traffic to the broker.
25-
*
26-
* @note All this function needs to do is call \ref __mqtt_recv and
27-
* \ref __mqtt_send every so often. I've picked 100 ms meaning that
25+
*
26+
* @note All this function needs to do is call \ref __mqtt_recv and
27+
* \ref __mqtt_send every so often. I've picked 100 ms meaning that
2828
* client ingress/egress traffic will be handled every 100 ms.
2929
*/
3030
void* client_refresher(void* client);
3131

3232
/**
33-
* @brief Safelty closes the \p sockfd and cancels the \p client_daemon before \c exit.
33+
* @brief Safelty closes the \p sockfd and cancels the \p client_daemon before \c exit.
3434
*/
3535
void exit_example(int status, BIO* sockfd, pthread_t *client_daemon);
3636

3737
/**
38-
* A simple program to that publishes the current time whenever ENTER is pressed.
38+
* A simple program to that publishes the current time whenever ENTER is pressed.
3939
*/
40-
int main(int argc, const char *argv[])
40+
int main(int argc, const char *argv[])
4141
{
4242
const char* addr;
4343
const char* port;
@@ -122,13 +122,13 @@ int main(int argc, const char *argv[])
122122
fprintf(stderr, "error: %s\n", mqtt_error_str(client.error));
123123
exit_example(EXIT_FAILURE, sockfd, &client_daemon);
124124
}
125-
}
125+
}
126126

127127
/* disconnect */
128128
printf("\n%s disconnecting from %s\n", argv[0], addr);
129129
sleep(1);
130130

131-
/* exit */
131+
/* exit */
132132
exit_example(EXIT_SUCCESS, sockfd, &client_daemon);
133133
}
134134

@@ -141,14 +141,14 @@ void exit_example(int status, BIO* sockfd, pthread_t *client_daemon)
141141

142142

143143

144-
void publish_callback(void** unused, struct mqtt_response_publish *published)
144+
void publish_callback(void** unused, struct mqtt_response_publish *published)
145145
{
146146
/* not used in this example */
147147
}
148148

149149
void* client_refresher(void* client)
150150
{
151-
while(1)
151+
while(1)
152152
{
153153
mqtt_sync((struct mqtt_client*) client);
154154
usleep(100000U);

examples/bio_publisher_win.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
/**
33
* @file
4-
* A simple program to that publishes the current time whenever ENTER is pressed.
4+
* A simple program to that publishes the current time whenever ENTER is pressed.
55
*/
66
#include <process.h>
77
#include <stdlib.h>
@@ -13,30 +13,30 @@
1313

1414
/**
1515
* @brief The function that would be called whenever a PUBLISH is received.
16-
*
17-
* @note This function is not used in this example.
16+
*
17+
* @note This function is not used in this example.
1818
*/
1919
void publish_callback(void** unused, struct mqtt_response_publish *published);
2020

2121
/**
22-
* @brief The client's refresher. This function triggers back-end routines to
22+
* @brief The client's refresher. This function triggers back-end routines to
2323
* handle ingress/egress traffic to the broker.
24-
*
25-
* @note All this function needs to do is call \ref __mqtt_recv and
26-
* \ref __mqtt_send every so often. I've picked 100 ms meaning that
24+
*
25+
* @note All this function needs to do is call \ref __mqtt_recv and
26+
* \ref __mqtt_send every so often. I've picked 100 ms meaning that
2727
* client ingress/egress traffic will be handled every 100 ms.
2828
*/
2929
void client_refresher(void* client);
3030

3131
/**
32-
* @brief Safelty closes the \p sockfd and cancels the \p client_daemon before \c exit.
32+
* @brief Safelty closes the \p sockfd and cancels the \p client_daemon before \c exit.
3333
*/
3434
void exit_example(int status, BIO* sockfd);
3535

3636
/**
37-
* A simple program to that publishes the current time whenever ENTER is pressed.
37+
* A simple program to that publishes the current time whenever ENTER is pressed.
3838
*/
39-
int main(int argc, const char *argv[])
39+
int main(int argc, const char *argv[])
4040
{
4141
const char* addr;
4242
const char* port;
@@ -120,13 +120,13 @@ int main(int argc, const char *argv[])
120120
fprintf(stderr, "\nerror: %s\n", mqtt_error_str(client.error));
121121
exit_example(EXIT_FAILURE, sockfd);
122122
}
123-
}
123+
}
124124

125125
/* disconnect */
126126
printf("\n%s disconnecting from %s\n", argv[0], addr);
127127
Sleep(1000);
128128

129-
/* exit */
129+
/* exit */
130130
exit_example(EXIT_SUCCESS, sockfd);
131131
}
132132

@@ -138,7 +138,7 @@ void exit_example(int status, BIO* sockfd)
138138

139139

140140

141-
void publish_callback(void** unused, struct mqtt_response_publish *published)
141+
void publish_callback(void** unused, struct mqtt_response_publish *published)
142142
{
143143
/* not used in this example */
144144
}

examples/mbedtls_publisher.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,30 @@
1212

1313
/**
1414
* @brief The function that would be called whenever a PUBLISH is received.
15-
*
16-
* @note This function is not used in this example.
15+
*
16+
* @note This function is not used in this example.
1717
*/
1818
void publish_callback(void** unused, struct mqtt_response_publish *published);
1919

2020
/**
21-
* @brief The client's refresher. This function triggers back-end routines to
21+
* @brief The client's refresher. This function triggers back-end routines to
2222
* handle ingress/egress traffic to the broker.
23-
*
24-
* @note All this function needs to do is call \ref __mqtt_recv and
25-
* \ref __mqtt_send every so often. I've picked 100 ms meaning that
23+
*
24+
* @note All this function needs to do is call \ref __mqtt_recv and
25+
* \ref __mqtt_send every so often. I've picked 100 ms meaning that
2626
* client ingress/egress traffic will be handled every 100 ms.
2727
*/
2828
void* client_refresher(void* client);
2929

3030
/**
31-
* @brief Safelty closes the \p sockfd and cancels the \p client_daemon before \c exit.
31+
* @brief Safelty closes the \p sockfd and cancels the \p client_daemon before \c exit.
3232
*/
3333
void exit_example(int status, mqtt_pal_socket_handle sockfd, pthread_t *client_daemon);
3434

3535
/**
36-
* A simple program to that publishes the current time whenever ENTER is pressed.
36+
* A simple program to that publishes the current time whenever ENTER is pressed.
3737
*/
38-
int main(int argc, const char *argv[])
38+
int main(int argc, const char *argv[])
3939
{
4040
const char* addr;
4141
const char* port;
@@ -127,13 +127,13 @@ int main(int argc, const char *argv[])
127127
fprintf(stderr, "error: %s\n", mqtt_error_str(client.error));
128128
exit_example(EXIT_FAILURE, sockfd, &client_daemon);
129129
}
130-
}
130+
}
131131

132132
/* disconnect */
133133
printf("\n%s disconnecting from %s\n", argv[0], addr);
134134
sleep(1);
135135

136-
/* exit */
136+
/* exit */
137137
exit_example(EXIT_SUCCESS, sockfd, &client_daemon);
138138
}
139139

@@ -147,14 +147,14 @@ void exit_example(int status, mqtt_pal_socket_handle sockfd, pthread_t *client_d
147147

148148

149149

150-
void publish_callback(void** unused, struct mqtt_response_publish *published)
150+
void publish_callback(void** unused, struct mqtt_response_publish *published)
151151
{
152152
/* not used in this example */
153153
}
154154

155155
void* client_refresher(void* client)
156156
{
157-
while(1)
157+
while(1)
158158
{
159159
mqtt_sync((struct mqtt_client*) client);
160160
usleep(100000U);

0 commit comments

Comments
 (0)