Skip to content
Snippets Groups Projects
Commit ae5732b9 authored by Zachary T Welch's avatar Zachary T Welch
Browse files

Add server port command helper function.

parent 653ea7b2
No related branches found
No related tags found
No related merge requests found
......@@ -549,3 +549,23 @@ int handle_shutdown_command(struct command_context_s *cmd_ctx, char *cmd, char *
return ERROR_COMMAND_CLOSE_CONNECTION;
}
int server_port_command(struct command_context_s *cmd_ctx,
char *cmd, char **args, int argc, unsigned short *out)
{
switch (argc) {
case 0:
command_print(cmd_ctx, "%d", *out);
break;
case 1:
{
uint16_t port;
COMMAND_PARSE_NUMBER(u16, args[0], port);
*out = port;
break;
}
default:
return ERROR_INVALID_ARGUMENTS;
}
return ERROR_OK;
}
......@@ -75,6 +75,9 @@ extern int server_quit(void);
extern int server_loop(command_context_t *command_context);
extern int server_register_commands(command_context_t *context);
int server_port_command(struct command_context_s *cmd_ctx,
char *cmd, char **args, int argc, unsigned short *port);
extern int server_use_pipes;
#define ERROR_SERVER_REMOTE_CLOSED (-400)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment