BitLab 0.1.0
BitLab: A Browser for the Bitcoin P2P Network and Blockchain
|
Go to the source code of this file.
Macros | |
#define | TIMESTAMP_LENGTH 20 |
#define | BUFFER_SIZE 8096 |
Functions | |
void | usleep (unsigned int usec) |
char * | strdup (const char *str1) |
char * | strndup (const char *src, size_t size) |
char * | strtok (char *str, const char *delimiters) |
int | fileno (FILE *__stream) |
struct tm * | localtime_r (const time_t *timer, struct tm *buf) |
void | flockfile (FILE *filehandle) |
void | funlockfile (FILE *file) |
FILE * | popen (const char *command, const char *type) |
int | pclose (FILE *stream) |
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. | |
void | log_to_file (const char *filename, const char *format,...) |
Log to file function. | |
uint64_t | ntohll (uint64_t value) |
Convert a 64-bit integer from host byte order to network byte order. | |
size_t | read_var_int (const unsigned char *data, uint64_t *value) |
Convert a 64-bit integer from network byte order to host byte order. | |
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().
int fileno | ( | FILE * | __stream | ) |
Referenced by log_message().
void flockfile | ( | FILE * | filehandle | ) |
Referenced by guarded_print(), and guarded_print_line().
void funlockfile | ( | FILE * | file | ) |
Referenced by guarded_print(), and guarded_print_line().
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().
struct tm * localtime_r | ( | const time_t * | timer, |
struct tm * | buf | ||
) |
Referenced by get_formatted_timestamp(), and get_timestamp().
void log_to_file | ( | const char * | filename, |
const char * | format, | ||
... | |||
) |
Log to file function.
This function is used to log messages to a specified file.
filename | The name of the log file. |
format | The format string. |
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.
int pclose | ( | FILE * | stream | ) |
Referenced by get_local_ip_address(), and get_remote_ip_address().
FILE * popen | ( | const char * | command, |
const char * | type | ||
) |
Referenced by get_local_ip_address(), and get_remote_ip_address().
size_t read_var_int | ( | const unsigned char * | data, |
uint64_t * | value | ||
) |
Convert a 64-bit integer from network byte order to host byte order.
value | The 64-bit integer in network byte order. |
Referenced by decode_transactions(), handle_inv_message(), parse_inv_message(), and send_getaddr_and_wait().
char * strdup | ( | const char * | str1 | ) |
Referenced by cli_command_generator().
char * strndup | ( | const char * | src, |
size_t | size | ||
) |
char * strtok | ( | char * | str, |
const char * | delimiters | ||
) |
Referenced by cli_exec_line(), and handle_peer_discovery().
void usleep | ( | unsigned int | usec | ) |
Referenced by cli_peer_discovery(), finish_logging(), handle_cli(), handle_peer_discovery(), log_message(), and run_bitlab().