BitLab 0.1.0
BitLab: A Browser for the Bitcoin P2P Network and Blockchain
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1#ifndef __UTILS_H
2#define __UTILS_H
3
4#include <stdio.h>
5#include <stddef.h>
6#include <stdint.h>
7#include <time.h>
8
9#include "log.h"
10
11#define TIMESTAMP_LENGTH 20
12#define BUFFER_SIZE 8096
13
14void usleep(unsigned int usec);
15char* strdup(const char* str1);
16char* strndup(const char* src, size_t size);
17char* strtok(char* str, const char* delimiters);
18
19int fileno(FILE* __stream);
20void usleep(unsigned int usec);
21
22struct tm* localtime_r(const time_t* timer, struct tm* buf);
23void flockfile(FILE* filehandle);
24void funlockfile(FILE* file);
25FILE* popen(const char* command, const char* type);
26int pclose(FILE* stream);
27
34void get_timestamp(char* buffer, size_t buffer_size);
35
42void get_formatted_timestamp(char* buffer, size_t buffer_size);
43
47void clear_cli();
48
52int init_config_dir();
53
59void guarded_print(const char* format, ...);
60
66void guarded_print_line(const char* format, ...);
67
68
75void log_to_file(const char* filename, const char* format, ...);
76
83uint64_t ntohll(uint64_t value);
84
91size_t read_var_int(const unsigned char* data, uint64_t* value);
92
99int is_valid_ipv4(const char* ip_str);
100
101#endif // __UTILS_H
uint64_t ntohll(uint64_t value)
Convert a 64-bit integer from host byte order to network byte order.
Definition utils.c:76
struct tm * localtime_r(const time_t *timer, struct tm *buf)
void log_to_file(const char *filename, const char *format,...)
Log to file function.
FILE * popen(const char *command, const char *type)
int fileno(FILE *__stream)
void get_formatted_timestamp(char *buffer, size_t buffer_size)
Get the formatted timestamp.
Definition utils.c:25
void flockfile(FILE *filehandle)
char * strdup(const char *str1)
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.
void clear_cli()
Clear the CLI window.
Definition utils.c:33
int is_valid_ipv4(const char *ip_str)
Check if the IP address is valid.
Definition utils.c:116
void get_timestamp(char *buffer, size_t buffer_size)
Get the timestamp.
Definition utils.c:17
void funlockfile(FILE *file)
void guarded_print_line(const char *format,...)
Guarded print line function.
Definition utils.c:65
void usleep(unsigned int usec)
char * strndup(const char *src, size_t size)
void guarded_print(const char *format,...)
Guarded print function.
Definition utils.c:55
int pclose(FILE *stream)
int init_config_dir()
Initialize the configuration directory.
Definition utils.c:38
char * strtok(char *str, const char *delimiters)