• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 18906446299

29 Oct 2025 11:32AM UTC coverage: 92.086% (+1.4%) from 90.674%
18906446299

push

github

web-flow
Merge pull request #5133 from randombit/jack/force-inline-keccak-f

Force the inlining of the Keccak permutation round function

101992 of 110757 relevant lines covered (92.09%)

11919381.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.78
/src/cli/socket_utils.h
1
/*
2
* (C) 2014,2017 Jack Lloyd
3
*     2017 René Korthaus, Rohde & Schwarz Cybersecurity
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#ifndef BOTAN_CLI_SOCKET_UTILS_H_
9
#define BOTAN_CLI_SOCKET_UTILS_H_
10

11
#include "cli_exceptions.h"
12
#include <botan/types.h>
13
#include <botan/internal/target_info.h>
14
#include <cstring>
15

16
#if defined(BOTAN_TARGET_OS_HAS_WINSOCK2)
17

18
   #include <WS2tcpip.h>
19
   #include <winsock2.h>
20

21
typedef SOCKET socket_type;
22

23
inline socket_type invalid_socket() {
24
   return INVALID_SOCKET;
25
}
26

27
typedef size_t ssize_t;
28
typedef int sendrecv_len_type;
29

30
inline void close_socket(socket_type s) {
31
   ::closesocket(s);
32
}
33

34
   #define STDIN_FILENO _fileno(stdin)
35

36
inline void init_sockets() {
37
   WSAData wsa_data;
38
   WORD wsa_version = MAKEWORD(2, 2);
39

40
   if(::WSAStartup(wsa_version, &wsa_data) != 0) {
41
      throw Botan_CLI::CLI_Error("WSAStartup() failed: " + std::to_string(WSAGetLastError()));
42
   }
43

44
   if(LOBYTE(wsa_data.wVersion) != 2 || HIBYTE(wsa_data.wVersion) != 2) {
45
      ::WSACleanup();
46
      throw Botan_CLI::CLI_Error("Could not find a usable version of Winsock.dll");
47
   }
48
}
49

50
inline void stop_sockets() {
51
   ::WSACleanup();
52
}
53

54
inline std::string err_to_string(int e) {
55
   // TODO use strerror_s here
56
   return "Error code " + std::to_string(e);
57
}
58

59
inline int close(int fd) {
60
   return ::closesocket(fd);
61
}
62

63
inline int read(int s, void* buf, size_t len) {
64
   return ::recv(s, reinterpret_cast<char*>(buf), static_cast<int>(len), 0);
65
}
66

67
inline int send(int s, const uint8_t* buf, size_t len, int flags) {
68
   return ::send(s, reinterpret_cast<const char*>(buf), static_cast<int>(len), flags);
69
}
70

71
#elif defined(BOTAN_TARGET_OS_HAS_POSIX1)
72

73
   #include <arpa/inet.h>
74
   #include <errno.h>
75
   #include <fcntl.h>
76
   #include <netdb.h>
77
   #include <netinet/in.h>
78
   #include <sys/socket.h>
79
   #include <sys/time.h>
80
   #include <sys/types.h>
81
   #include <unistd.h>
82

83
typedef int socket_type;
84
typedef size_t sendrecv_len_type;
85

86
inline socket_type invalid_socket() {
13✔
87
   return -1;
13✔
88
}
89

90
inline void close_socket(socket_type s) {
12✔
91
   ::close(s);
12✔
92
}
12✔
93

94
inline void init_sockets() {}
13✔
95

96
inline void stop_sockets() {}
13✔
97

98
inline std::string err_to_string(int e) {
×
99
   return std::strerror(e);
×
100
}
101

102
#endif
103

104
#if !defined(MSG_NOSIGNAL)
105
   #define MSG_NOSIGNAL 0
106
#endif
107

108
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc