time_since(const struct timeval *when)
{
struct timeval now;
- gettimeofday(&now, NULL);
+ gettimeofday(&now, nullptr);
return timeval_diff(when, &now);
}
static void
random_vector(char *aVector)
{
- static std::mt19937 mt(time(0));
+ static std::mt19937 mt(time(nullptr));
static xuniform_int_distribution<uint8_t> dist;
for (int i = 0; i < AUTH_VECTOR_LEN; ++i)
char line[MAXLINE];
int srv = 0, crt = 0;
- if ((cf = fopen(cfname, "r")) == NULL) {
+ if ((cf = fopen(cfname, "r")) == nullptr) {
perror(cfname);
return -1;
}
- while (fgets(line, MAXLINE, cf) != NULL) {
+ while (fgets(line, MAXLINE, cf) != nullptr) {
if (!memcmp(line, "server", 6))
srv = sscanf(line, "server %s", server);
if (!memcmp(line, "secret", 6))
++src;
tmp[1] = *src;
++src;
- *dst = strtol(tmp, NULL, 16);
+ *dst = strtol(tmp, nullptr, 16);
++dst;
} else {
*dst = *src;
/*
* Send the request we've built.
*/
- gettimeofday(&sent, NULL);
+ gettimeofday(&sent, nullptr);
if (send(socket_fd, (char *) auth, total_length, 0) < 0) {
int xerrno = errno;
// EAGAIN is expected at high traffic, just retry
}
FD_ZERO(&readfds);
FD_SET(socket_fd, &readfds);
- if (select(socket_fd + 1, &readfds, NULL, NULL, &tv) == 0) /* Select timeout */
+ if (select(socket_fd + 1, &readfds, nullptr, nullptr, &tv) == 0) /* Select timeout */
break;
salen = sizeof(saremote);
len = recvfrom(socket_fd, recv_buffer, sizeof(i_recv_buffer),
char passwd[MAXPASS];
char *ptr;
char buf[HELPER_INPUT_BUFFER];
- const char *cfname = NULL;
+ const char *cfname = nullptr;
int err = 0;
socklen_t salen;
int c;
}
}
/* make standard output line buffered */
- if (setvbuf(stdout, NULL, _IOLBF, 0) != 0)
+ if (setvbuf(stdout, nullptr, _IOLBF, 0) != 0)
exit(EXIT_FAILURE);
if (cfname) {
* Open a connection to the server.
*/
svp = getservbyname(svc_name, "udp");
- if (svp != NULL)
+ if (svp != nullptr)
svc_port = ntohs((unsigned short) svp->s_port);
else
svc_port = atoi(svc_name);
}
#endif
nas_ipaddr = ntohl(salocal.sin_addr.s_addr);
- while (fgets(buf, HELPER_INPUT_BUFFER, stdin) != NULL) {
+ while (fgets(buf, HELPER_INPUT_BUFFER, stdin) != nullptr) {
char *end;
/* protect me form to long lines */
- if ((end = strchr(buf, '\n')) == NULL) {
+ if ((end = strchr(buf, '\n')) == nullptr) {
err = 1;
continue;
}
ptr = buf;
while (isspace(*ptr))
++ptr;
- if ((end = strchr(ptr, ' ')) == NULL) {
+ if ((end = strchr(ptr, ' ')) == nullptr) {
SEND_ERR("No password");
continue;
}