25 if (argc > 1 && argv != NULL)
29 for (
int i = 1; i < argc; ++i)
30 total_length += strlen(argv[i]) + 1;
32 char* line = (
char*)malloc(total_length *
sizeof(
char));
38 for (
int i = 1; i < argc; ++i)
40 strcat(line, argv[i]);
45 if (argv[1] && strcmp(argv[1],
"exit") == 0)
59 pthread_join(cli_thread, NULL);
60 pthread_join(peer_discovery_thread, NULL);
bitlab_result run_bitlab(int argc, char *argv[])
Run the BitLab program.
void * handle_cli(void *arg)
CLI handler thread.
int cli_exec_line(char *line)
Execute command.
void finish_logging()
Finish logging used to finish logging and close the log file.
void log_message(log_level level, const char *filename, const char *source_file, const char *format,...)
Log a message used to log a message to the console or a file.
#define LOG_BITLAB_FINISHED
#define LOG_BITLAB_STARTED
void init_logging(const char *filename)
Initialize logging used to initialize the logging system, open and preserve the log file.
void * handle_peer_discovery(void *arg)
Peer discovery handler thread.
void destroy_program_state()
Destroy the program state.
void destroy_program_operation()
Clear all program operations.
program_state state
The program state used to store the state of the program.
void mark_started_with_parameters()
Mark the program as started with parameters.
int init_program_operation()
Initialize the program operation.
program_operation operation
The program operation used to store all current operations of the program.
sig_atomic_t get_exit_flag()
Get the exit flag.
void init_program_state()
Initialize the program state.
pthread_t thread_runner(void *(*start_routine)(void *), const char *name, void *arg)
Thread runner function.
void guarded_print_line(const char *format,...)
Guarded print line function.
void usleep(unsigned int usec)
int init_config_dir()
Initialize the configuration directory.