summaryrefslogtreecommitdiff
path: root/tests/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/utils.c')
-rw-r--r--tests/utils.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/tests/utils.c b/tests/utils.c
index f551eddf1f..66fc7f7897 100644
--- a/tests/utils.c
+++ b/tests/utils.c
@@ -20,7 +20,7 @@
*/
#ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
#endif
#include <stdio.h>
@@ -31,12 +31,12 @@
#include <assert.h>
#include <errno.h>
#ifndef _WIN32
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
+# include <netinet/in.h>
+# include <sys/socket.h>
+# include <arpa/inet.h>
#else
-#include <windows.h> /* for Sleep */
-#include <winbase.h>
+# include <windows.h> /* for Sleep */
+# include <winbase.h>
#endif
#include <gnutls/gnutls.h>
@@ -83,8 +83,7 @@ const char *pkcs3_3072 =
"ssbzSibBsu/6iGtCOGEfz9zeNVs7ZRkDW7w09N75nAI4YbRvydbmyQd62R0mkff3\n"
"7lmMsPrBhtkcrv4TCYUTknC0EwyTvEN5RPT9RFLi103TZPLiHnH1S/9croKrnJ32\n"
"nuhtK8UiNjoNq8Uhl5sN6todv5pC1cRITgq80Gv6U93vPBsg7j/VnXwl5B0rZsYu\n"
- "N///////////AgEC\n"
- "-----END DH PARAMETERS-----\n";
+ "N///////////AgEC\n" "-----END DH PARAMETERS-----\n";
void _fail(const char *format, ...)
{
@@ -210,14 +209,14 @@ void binprint(const void *_str, size_t len)
printf("\t;; ");
for (i = 0; i < len; i++) {
printf("%d%d%d%d%d%d%d%d ",
- (str[i] & 0xFF) & 0x80 ? 1 : 0,
- (str[i] & 0xFF) & 0x40 ? 1 : 0,
- (str[i] & 0xFF) & 0x20 ? 1 : 0,
- (str[i] & 0xFF) & 0x10 ? 1 : 0,
- (str[i] & 0xFF) & 0x08 ? 1 : 0,
- (str[i] & 0xFF) & 0x04 ? 1 : 0,
- (str[i] & 0xFF) & 0x02 ? 1 : 0,
- (str[i] & 0xFF) & 0x01 ? 1 : 0);
+ (str[i] & 0xFF) & 0x80 ? 1 : 0,
+ (str[i] & 0xFF) & 0x40 ? 1 : 0,
+ (str[i] & 0xFF) & 0x20 ? 1 : 0,
+ (str[i] & 0xFF) & 0x10 ? 1 : 0,
+ (str[i] & 0xFF) & 0x08 ? 1 : 0,
+ (str[i] & 0xFF) & 0x04 ? 1 : 0,
+ (str[i] & 0xFF) & 0x02 ? 1 : 0,
+ (str[i] & 0xFF) & 0x01 ? 1 : 0);
if ((i + 1) % 3 == 0)
printf(" ");
if ((i + 1) % 6 == 0 && i + 1 < len)
@@ -249,7 +248,7 @@ int main(int argc, char *argv[])
if (debug || error_count > 0)
printf("Self test `%s' finished with %d errors\n", argv[0],
- error_count);
+ error_count);
return error_count ? 1 : 0;
}
@@ -259,13 +258,13 @@ struct tmp_file_st {
struct tmp_file_st *next;
};
-static struct tmp_file_st *temp_files = (void*)-1;
+static struct tmp_file_st *temp_files = (void *)-1;
static void append(const char *file)
{
struct tmp_file_st *p;
- if (temp_files == (void*)-1)
+ if (temp_files == (void *)-1)
return;
p = calloc(1, sizeof(*p));
@@ -297,8 +296,9 @@ char *get_tmpname(char s[TMPNAME_SIZE])
else
p = s;
- snprintf(p, TMPNAME_SIZE, "%s/tmpfile-%02x%02x%02x%02x%02x%02x.tmp", path, (unsigned)rnd[0], (unsigned)rnd[1],
- (unsigned)rnd[2], (unsigned)rnd[3], (unsigned)rnd[4], (unsigned)rnd[5]);
+ snprintf(p, TMPNAME_SIZE, "%s/tmpfile-%02x%02x%02x%02x%02x%02x.tmp",
+ path, (unsigned)rnd[0], (unsigned)rnd[1], (unsigned)rnd[2],
+ (unsigned)rnd[3], (unsigned)rnd[4], (unsigned)rnd[5]);
append(p);
@@ -315,10 +315,10 @@ void delete_temp_files(void)
struct tmp_file_st *p = temp_files;
struct tmp_file_st *next;
- if (p == (void*)-1)
+ if (p == (void *)-1)
return;
- while(p != NULL) {
+ while (p != NULL) {
remove(p->file);
next = p->next;
free(p);
@@ -326,9 +326,8 @@ void delete_temp_files(void)
}
}
-
#ifndef _WIN32
-int tcp_connect(const char* addr, unsigned port)
+int tcp_connect(const char *addr, unsigned port)
{
int sock;
struct sockaddr_in sa;
@@ -343,7 +342,7 @@ int tcp_connect(const char* addr, unsigned port)
close(sock);
return -1;
}
- if (connect(sock, (struct sockaddr*) &sa, sizeof(sa)) != 0) {
+ if (connect(sock, (struct sockaddr *)&sa, sizeof(sa)) != 0) {
close(sock);
return -1;
}