#include "gnunet_os_lib.h"
#include <gcrypt.h>
+#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
+
+#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util", syscall)
+
/**
* Create a cryptographically weak pseudo-random number in the interval of 0 to 1.
- *
+ *
* @return number between 0 and 1.
*/
static double
ul = UINT32_MAX - (UINT32_MAX % i);
do
{
- gcry_randomize ((unsigned char *) &ret,
- sizeof (uint32_t), GCRY_STRONG_RANDOM);
+ gcry_randomize ((unsigned char *) &ret, sizeof (uint32_t),
+ GCRY_STRONG_RANDOM);
}
while (ret >= ul);
return ret % i;
ul = UINT64_MAX - (UINT64_MAX % max);
do
{
- gcry_randomize ((unsigned char *) &ret,
- sizeof (uint64_t), GCRY_STRONG_RANDOM);
+ gcry_randomize ((unsigned char *) &ret, sizeof (uint64_t),
+ GCRY_STRONG_RANDOM);
}
while (ret >= ul);
return ret % max;
* blocked gathering entropy.
*/
static void
-entropy_generator (void *cls,
- const char *what, int printchar, int current, int total)
+entropy_generator (void *cls, const char *what, int printchar, int current,
+ int total)
{
unsigned long code;
enum GNUNET_OS_ProcessStatusType type;
if (genproc != NULL)
{
if (0 != GNUNET_OS_process_kill (genproc, SIGTERM))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "kill");
+ LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "kill");
GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (genproc));
GNUNET_OS_process_close (genproc);
genproc = NULL;
return;
}
if (0 != GNUNET_OS_process_kill (genproc, SIGTERM))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "kill");
+ LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "kill");
GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (genproc));
GNUNET_OS_process_close (genproc);
genproc = NULL;
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Starting `%s' process to generate entropy\n"), "find");
- genproc = GNUNET_OS_start_process (NULL, NULL, "sh",
- "sh",
- "-c",
- "exec find / -mount -type f -exec cp {} /dev/null \\; 2>/dev/null",
- NULL);
+ LOG (GNUNET_ERROR_TYPE_INFO, _("Starting `%s' process to generate entropy\n"),
+ "find");
+ genproc =
+ GNUNET_OS_start_process (NULL, NULL, "sh", "sh", "-c",
+ "exec find / -mount -type f -exec cp {} /dev/null \\; 2>/dev/null",
+ NULL);
}
_
("libgcrypt has not the expected version (version %s is required).\n"),
GCRYPT_VERSION);
- abort ();
+ GNUNET_abort ();
}
#ifdef gcry_fast_random_poll
gcry_fast_random_poll ();