Show error if disconnected unintentionally

master
Curtis McEnroe 2018-12-04 15:56:10 -05:00
parent b1427dd169
commit 638be4e775
No known key found for this signature in database
GPG Key ID: CEA2F97ADCFCD77C
4 changed files with 15 additions and 6 deletions

1
chat.h
View File

@ -44,6 +44,7 @@ struct {
char *join; char *join;
bool verbose; bool verbose;
bool notify; bool notify;
bool quit;
} self; } self;
void eventWait(const char *argv[static 2]); void eventWait(const char *argv[static 2]);

View File

@ -131,10 +131,14 @@ noreturn void eventLoop(void) {
for (;;) { for (;;) {
if (sig[SIGCHLD]) childWait(); if (sig[SIGCHLD]) childWait();
if (sig[SIGHUP]) ircFmt("QUIT :zzz\r\n"); if (sig[SIGHUP]) {
ircFmt("QUIT :zzz\r\n");
self.quit = true;
}
if (sig[SIGINT]) { if (sig[SIGINT]) {
signal(SIGINT, SIG_DFL); signal(SIGINT, SIG_DFL);
ircFmt("QUIT :Goodbye\r\n"); ircFmt("QUIT :Goodbye\r\n");
self.quit = true;
} }
if (sig[SIGWINCH]) { if (sig[SIGWINCH]) {
curses.sa_handler(SIGWINCH); curses.sa_handler(SIGWINCH);

View File

@ -95,11 +95,14 @@ static void handlePing(char *prefix, char *params) {
} }
static void handleError(char *prefix, char *params) { static void handleError(char *prefix, char *params) {
(void)prefix; char *mesg;
(void)params; parse(prefix, NULL, NULL, NULL, params, 1, 0, &mesg);
// TODO: Show error if unintended disconnect. if (self.quit) {
uiExit(); uiExit();
exit(EX_OK); exit(EX_OK);
} else {
errx(EX_PROTOCOL, "%s", mesg);
}
} }
static void handleErrorErroneousNickname(char *prefix, char *params) { static void handleErrorErroneousNickname(char *prefix, char *params) {

View File

@ -106,6 +106,7 @@ static void inputTopic(struct Tag tag, char *params) {
static void inputQuit(struct Tag tag, char *params) { static void inputQuit(struct Tag tag, char *params) {
(void)tag; (void)tag;
ircFmt("QUIT :%s\r\n", params ? params : "Goodbye"); ircFmt("QUIT :%s\r\n", params ? params : "Goodbye");
self.quit = true;
} }
static void inputURL(struct Tag tag, char *params) { static void inputURL(struct Tag tag, char *params) {