Some utils facilitating the view into the internals for the sampler needed for evaluation. More...
Go to the source code of this file.
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "rps-test_util", __VA_ARGS__) |
#define | B2B_PAT "%c%c%c%c%c%c%c%c" |
#define | B2B(byte) |
Functions | |
struct GNUNET_DISK_FileHandle * | get_file_handle (const char *name) |
Get file handle. More... | |
int | close_files_iter (void *cls, const struct GNUNET_HashCode *key, void *value) |
Closes the file of the current entry. More... | |
int | close_all_files () |
Close all files that were opened with get_file_handle. More... | |
void | to_file_raw (const char *file_name, const char *buf, size_t size_buf) |
void | to_file_raw_unaligned (const char *file_name, const char *buf, size_t size_buf, unsigned bits_needed) |
char * | auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key) |
struct GNUNET_CRYPTO_AuthKey | string_to_auth_key (const char *str) |
static int | ensure_folder_exist (void) |
Try to ensure that /tmp/rps exists. More... | |
char * | store_prefix_file_name (const unsigned int index, const char *prefix) |
uint32_t | fac (uint32_t x) |
Factorial. More... | |
uint32_t | binom (uint32_t n, uint32_t k) |
Binomial coefficient (n choose k) More... | |
Variables | |
static char | buf_unaligned |
buffer for storing the unaligned bits for the next write More... | |
static unsigned | num_bits_buf_unaligned |
number of bits in unaligned buffer More... | |
static struct GNUNET_CONTAINER_MultiHashMap * | open_files |
Some utils facilitating the view into the internals for the sampler needed for evaluation.
Definition in file rps-test_util.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "rps-test_util", __VA_ARGS__) |
Definition at line 35 of file rps-test_util.c.
#define B2B_PAT "%c%c%c%c%c%c%c%c" |
Definition at line 37 of file rps-test_util.c.
#define B2B | ( | byte | ) |
Definition at line 38 of file rps-test_util.c.
struct GNUNET_DISK_FileHandle * get_file_handle | ( | const char * | name | ) |
Get file handle.
If necessary, create file handle and store it with the other file handles.
name | Name of the file |
Definition at line 74 of file rps-test_util.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_hash(), GNUNET_DISK_file_open(), GNUNET_DISK_OPEN_APPEND, GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_WRITE, GNUNET_DISK_PERM_GROUP_READ, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_NO, GNUNET_YES, LOG, name, and open_files.
int close_files_iter | ( | void * | cls, |
const struct GNUNET_HashCode * | key, | ||
void * | value | ||
) |
Closes the file of the current entry.
Implements #GNUNET_CONTAINER_HashMapIterator
cls | unused |
key | unused |
value | the file handle |
Definition at line 129 of file rps-test_util.c.
References GNUNET_DISK_file_close(), GNUNET_YES, key, and value.
Referenced by close_all_files().
int close_all_files | ( | ) |
Close all files that were opened with get_file_handle.
Definition at line 151 of file rps-test_util.c.
References close_files_iter(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_YES, open_files, and ret.
Referenced by shutdown_task().
void to_file_raw | ( | const char * | file_name, |
const char * | buf, | ||
size_t | size_buf | ||
) |
Definition at line 169 of file rps-test_util.c.
References removetrailingwhitespace::f, file_name, GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_write(), GNUNET_DISK_OPEN_APPEND, GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_WRITE, GNUNET_DISK_PERM_GROUP_READ, GNUNET_DISK_PERM_OTHER_READ, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_WARNING, GNUNET_YES, and LOG.
Referenced by to_file_raw_unaligned().
void to_file_raw_unaligned | ( | const char * | file_name, |
const char * | buf, | ||
size_t | size_buf, | ||
unsigned | bits_needed | ||
) |
Definition at line 213 of file rps-test_util.c.
References B2B, B2B_PAT, buf_unaligned, file_name, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MIN, LOG, num_bits_buf_unaligned, and to_file_raw().
char * auth_key_to_string | ( | struct GNUNET_CRYPTO_AuthKey | auth_key | ) |
Definition at line 380 of file rps-test_util.c.
References end, GNUNET_break, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_malloc, GNUNET_snprintf(), GNUNET_STRINGS_data_to_string(), GNUNET_CRYPTO_AuthKey::key, LOG, and size.
struct GNUNET_CRYPTO_AuthKey string_to_auth_key | ( | const char * | str | ) |
Definition at line 426 of file rps-test_util.c.
References GNUNET_ERROR_TYPE_WARNING, GNUNET_OK, GNUNET_STRINGS_string_to_data(), GNUNET_CRYPTO_AuthKey::key, and LOG.
|
static |
Try to ensure that /tmp/rps
exists.
Definition at line 450 of file rps-test_util.c.
References GNUNET_DISK_directory_create(), GNUNET_ERROR_TYPE_ERROR, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, and LOG.
Referenced by store_prefix_file_name().
char * store_prefix_file_name | ( | const unsigned int | index, |
const char * | prefix | ||
) |
Definition at line 464 of file rps-test_util.c.
References ensure_folder_exist(), file_name, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_malloc, GNUNET_snprintf(), GNUNET_SYSERR, and prefix.
uint32_t fac | ( | uint32_t | x | ) |
Factorial.
x | Number of which to compute the factorial |
Definition at line 516 of file rps-test_util.c.
References fac().
Referenced by binom(), and fac().
uint32_t binom | ( | uint32_t | n, |
uint32_t | k | ||
) |
Binomial coefficient (n choose k)
n | |
k |
Definition at line 535 of file rps-test_util.c.
References fac().
|
static |
buffer for storing the unaligned bits for the next write
Definition at line 54 of file rps-test_util.c.
Referenced by to_file_raw_unaligned().
|
static |
number of bits in unaligned buffer
Definition at line 59 of file rps-test_util.c.
Referenced by to_file_raw_unaligned().
|
static |
Definition at line 61 of file rps-test_util.c.
Referenced by close_all_files(), and get_file_handle().