toxcore/toxcore/util.c
Jin^eLD e092eee869 Allow to build vs nacl instead of libsodium
By default libsodium is used. Only if --enable-nacl is specified, then
nacl will be used instead of libsodium.

Pass locations of nacl headers and libraries by using the following
options:

--with-nacl-headers=/home/me/somewhere/nacl-20110221/build/469/include/amd64/
--with-nacl-libs=/home/me/somewhere/nacl-20110221/build/469/lib/amd64/
2013-09-06 22:54:45 +03:00

49 lines
719 B
C

/*
* util.c -- Utilities.
*
* This file is donated to the Tox Project.
* Copyright 2013 plutooo
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <time.h>
#include <stdint.h>
#include <stdbool.h>
#include "DHT.h"
uint64_t now()
{
return time(NULL);
}
uint64_t random_64b()
{
uint64_t r;
// This is probably not random enough?
r = random_int();
r <<= 32;
r |= random_int();
return r;
}
bool ipp_eq(IP_Port a, IP_Port b)
{
return (a.ip.uint32 == b.ip.uint32) && (a.port == b.port);
}
bool id_eq(uint8_t *dest, uint8_t *src)
{
return memcmp(dest, src, CLIENT_ID_SIZE) == 0;
}
void id_cpy(uint8_t *dest, uint8_t *src)
{
memcpy(dest, src, CLIENT_ID_SIZE);
}