BitLab 0.1.0
BitLab: A Browser for the Bitcoin P2P Network and Blockchain
Loading...
Searching...
No Matches
cli.h
Go to the documentation of this file.
1#ifndef __CLI_H
2#define __CLI_H
3
4#include <stdio.h>
5#include <stdlib.h>
6
7#define MAX_LINE_LEN 256
8#define CLI_BUFSIZE 64
9#define CLI_DELIM " "
10#define CLI_COMMANDS_NUM (int) (sizeof(cli_commands) / sizeof(cli_command))
11#define CLI_HISTORY_FILE "cli_history.txt"
12#define CLI_PREFIX "BitLab> "
13
23typedef struct
24{
25 int (*cli_command)(char** args);
26 const char* cli_command_name;
29 const char* cli_command_usage;
31
32
34
38void print_help();
39
45void print_usage(const char* command_name);
46
50void print_commands();
51
52
54
60const char* create_history_dir();
61
62
64
71int cli_exit(char** args);
72
79int cli_history(char** args);
80
87int cli_echo(char** args);
88
95int cli_whoami(char** args);
96
103int cli_get_ip(char** args);
104
111int cli_info(char** args);
112
119int cli_peer_discovery(char** args);
120
127int cli_clear(char** args);
128
135int cli_help(char** args);
136
143int cli_ping(char** args);
144
151int cli_connect(char** args);
152
159int cli_list(char** args);
160
167int cli_getaddr(char** args);
168
178int cli_disconnect(char** args);
179
186int cli_getheaders(char** args);
187
194int cli_getblocks(char** args);
195
202int cli_inv(char** args);
203
210int cli_getdata(char** args);
211
218int cli_tx(char** args);
219
220
222
231int cli_get_line(char** lineptr, size_t* n, FILE* stream);
232
240char* cli_read_line(void);
241
248int cli_exec_line(char* line);
249
250
252
261char** cli_completion(const char* text, int start, int end);
262
270char* cli_command_generator(const char* text, int state);
271
272
274
280void* handle_cli(void* arg);
281
282#endif // __CLI_H
char * cli_command_generator(const char *text, int state)
CLI command generator.
Definition cli.c:1258
void print_usage(const char *command_name)
Prints CLI command usage.
Definition cli.c:262
void print_commands()
Prints CLI commands.
Definition cli.c:275
int cli_history(char **args)
Prints CLI command history.
Definition cli.c:312
const char * create_history_dir()
Create history directory.
Definition cli.c:1328
int cli_clear(char **args)
Clears CLI window.
Definition cli.c:1098
int cli_help(char **args)
Prints CLI command help.
Definition cli.c:333
int cli_whoami(char **args)
Prints the user name.
Definition cli.c:385
char ** cli_completion(const char *text, int start, int end)
CLI completion function.
Definition cli.c:1225
int cli_peer_discovery(char **args)
Discovers Bitcoin peers.
Definition cli.c:528
int cli_getdata(char **args)
Sends a 'getdata' message to specified peer.
Definition cli.c:908
int cli_tx(char **args)
Sends a 'tx' message to specified peer.
Definition cli.c:1036
int cli_connect(char **args)
Connects to the specified IP address.
Definition cli.c:768
char * cli_read_line(void)
Reads input from user.
Definition cli.c:1153
int cli_disconnect(char **args)
Disconnects from the specified node.
Definition cli.c:830
void * handle_cli(void *arg)
CLI handler thread.
Definition cli.c:1278
void print_help()
Prints CLI command help.
Definition cli.c:171
int cli_get_line(char **lineptr, size_t *n, FILE *stream)
Gets the line from the file stream.
Definition cli.c:1114
int cli_getblocks(char **args)
Sends a 'getblocks' message to specified peer.
Definition cli.c:882
int cli_info(char **args)
Prints program information.
Definition cli.c:481
int cli_get_ip(char **args)
Gets remote IP address on an URL or host machine if no URL is provided.
Definition cli.c:437
int cli_getheaders(char **args)
Sends a 'getheaders' message to specified peer.
Definition cli.c:856
int cli_getaddr(char **args)
Sends a 'getaddr' message to the specified peer.
Definition cli.c:804
int cli_inv(char **args)
Sends a 'inv' message to specified peer.
Definition cli.c:992
int cli_exit(char **args)
Exits BitLab CLI command.
Definition cli.c:281
int cli_exec_line(char *line)
Execute command.
Definition cli.c:1163
int cli_echo(char **args)
Echoes the input.
Definition cli.c:367
int cli_ping(char **args)
Pings the specified IP address.
Definition cli.c:694
int cli_list(char **args)
Lists all connected nodes.
Definition cli.c:1082
program_state state
The program state used to store the state of the program.
Definition state.c:19
CLI command structure.
Definition cli.h:24
const char * cli_command_brief_desc
Definition cli.h:27
const char * cli_command_usage
Definition cli.h:29
const char * cli_command_detailed_desc
Definition cli.h:28
const char * cli_command_name
Definition cli.h:26