BitLab 0.1.0
BitLab: A Browser for the Bitcoin P2P Network and Blockchain
|
#include "utils.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <netinet/in.h>
Go to the source code of this file.
Functions | |
void | get_timestamp (char *buffer, size_t buffer_size) |
Get the timestamp. | |
void | get_formatted_timestamp (char *buffer, size_t buffer_size) |
Get the formatted timestamp. | |
void | clear_cli () |
Clear the CLI window. | |
int | init_config_dir () |
Initialize the configuration directory. | |
void | guarded_print (const char *format,...) |
Guarded print function. | |
void | guarded_print_line (const char *format,...) |
Guarded print line function. | |
uint64_t | ntohll (uint64_t value) |
Convert a 64-bit integer from host byte order to network byte order. | |
uint64_t | read_var_int (const unsigned char *data, size_t *offset) |
int | is_valid_ipv4 (const char *ip_str) |
Check if the IP address is valid. | |
void clear_cli | ( | ) |
Clear the CLI window.
Definition at line 33 of file utils.c.
References guarded_print().
Referenced by cli_clear().
void get_formatted_timestamp | ( | char * | buffer, |
size_t | buffer_size | ||
) |
Get the formatted timestamp.
This function is used to get the formatted timestamp in a YYYY-MM-DD HH:MM:SS format.
buffer | The buffer to store the formatted timestamp. |
buffer_size | The size of the buffer. |
Definition at line 25 of file utils.c.
References localtime_r().
Referenced by log_message().
void get_timestamp | ( | char * | buffer, |
size_t | buffer_size | ||
) |
Get the timestamp.
This function is used to get the timestamp in a YYYYMMDDHHMMSS format.
buffer | The buffer to store the timestamp. |
buffer_size | The size of the buffer. |
Definition at line 17 of file utils.c.
References localtime_r().
void guarded_print | ( | const char * | format, |
... | |||
) |
Guarded print function.
This function is used to lock the stdout file and print the formatted string.
format | The format string. |
Definition at line 55 of file utils.c.
References flockfile(), and funlockfile().
Referenced by clear_cli(), cli_completion(), cli_echo(), load_blocks_from_file(), parse_inv_message(), save_blocks_to_file(), send_getblocks_and_wait(), and send_getheaders_and_wait().
void guarded_print_line | ( | const char * | format, |
... | |||
) |
Guarded print line function.
This function is used to lock the stdout file and print the formatted string.
format | The format string. |
Definition at line 65 of file utils.c.
References flockfile(), and funlockfile().
Referenced by cli_connect(), cli_disconnect(), cli_exec_line(), cli_get_ip(), cli_getaddr(), cli_getblocks(), cli_getdata(), cli_getheaders(), cli_help(), cli_history(), cli_info(), cli_peer_discovery(), cli_ping(), cli_tx(), cli_whoami(), connect_to_peer(), handle_peer_discovery(), list_connected_nodes(), print_commands(), print_help(), print_peer_queue(), print_program_state(), print_usage(), run_bitlab(), send_addr(), and send_getaddr_and_wait().
int init_config_dir | ( | ) |
Initialize the configuration directory.
Definition at line 38 of file utils.c.
Referenced by run_bitlab().
int is_valid_ipv4 | ( | const char * | ip_str | ) |
Check if the IP address is valid.
ip_str | The IP address string. |
Definition at line 116 of file utils.c.
Referenced by send_getaddr_and_wait().
uint64_t ntohll | ( | uint64_t | value | ) |
Convert a 64-bit integer from host byte order to network byte order.
value | The 64-bit integer in host byte order. |
Definition at line 76 of file utils.c.
uint64_t read_var_int | ( | const unsigned char * | data, |
size_t * | offset | ||
) |
Definition at line 88 of file utils.c.