1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Moved start commands to command.module

This commit is contained in:
James Booth 2012-02-10 23:53:13 +00:00
parent 0e30c795a5
commit 9db56f4fc1
3 changed files with 35 additions and 37 deletions

View File

@ -11,6 +11,36 @@ static int cmd_msg(char *cmd);
static int cmd_close(char *cmd);
static int cmd_default(char *cmd);
int handle_start_command(char *cmd)
{
int result;
if (strcmp(cmd, "/quit") == 0) {
result = QUIT_PROF;
} else if (strncmp(cmd, "/help", 5) == 0) {
cons_help();
inp_clear();
result = AWAIT_COMMAND;
} else if (strncmp(cmd, "/connect ", 9) == 0) {
char *user;
user = strndup(cmd+9, strlen(cmd)-9);
inp_bar_get_password();
char passwd[20];
inp_get_password(passwd);
inp_bar_print_message(user);
jabber_connect(user, passwd);
result = START_MAIN;
} else {
cons_bad_command(cmd);
inp_clear();
result = AWAIT_COMMAND;
}
return result;
}
int handle_command(char *cmd)
{
int result = FALSE;

View File

@ -1,6 +1,11 @@
#ifndef COMMAND_H
#define COMMAND_H
#define AWAIT_COMMAND 1
#define START_MAIN 2
#define QUIT_PROF 3
int handle_start_command(char *cmd);
int handle_command(char *cmd);
#endif

View File

@ -9,12 +9,6 @@
#include "jabber.h"
#include "command.h"
#define AWAIT_COMMAND 1
#define START_MAIN 2
#define QUIT_PROF 3
static int handle_start_command(char *cmd);
static void profanity_main(void);
static void profanity_event_loop(int *ch, char *cmd, int *size);
@ -88,34 +82,3 @@ static void profanity_event_loop(int *ch, char *cmd, int *size)
// get another character from the command box
inp_poll_char(ch, cmd, size);
}
static int handle_start_command(char *cmd)
{
int result;
if (strcmp(cmd, "/quit") == 0) {
result = QUIT_PROF;
} else if (strncmp(cmd, "/help", 5) == 0) {
cons_help();
inp_clear();
result = AWAIT_COMMAND;
} else if (strncmp(cmd, "/connect ", 9) == 0) {
char *user;
user = strndup(cmd+9, strlen(cmd)-9);
inp_bar_get_password();
char passwd[20];
inp_get_password(passwd);
inp_bar_print_message(user);
jabber_connect(user, passwd);
result = START_MAIN;
} else {
cons_bad_command(cmd);
inp_clear();
result = AWAIT_COMMAND;
}
return result;
}