1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-23 21:45:30 +00:00
profanity/profanity.c

75 lines
1.7 KiB
C
Raw Normal View History

2012-02-20 20:07:38 +00:00
/*
* profanity.c
*
* Copyright (C) 2012 James Booth <boothj5@gmail.com>
*
* This file is part of Profanity.
*
* Profanity is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Profanity is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Profanity. If not, see <http://www.gnu.org/licenses/>.
*
*/
2012-02-09 22:24:03 +00:00
#include <string.h>
#include <stdlib.h>
2012-02-09 22:24:03 +00:00
#include <ncurses.h>
#include "profanity.h"
2012-02-05 15:10:10 +00:00
#include "log.h"
2012-02-05 23:08:15 +00:00
#include "windows.h"
2012-02-09 22:24:03 +00:00
#include "jabber.h"
2012-02-09 23:15:53 +00:00
#include "command.h"
2012-02-27 01:44:09 +00:00
#include "history.h"
2012-02-09 22:24:03 +00:00
static void _profanity_shutdown(void);
2012-03-01 01:44:47 +00:00
void profanity_run(void)
2012-02-09 22:50:19 +00:00
{
2012-02-09 23:15:53 +00:00
int cmd_result = TRUE;
2012-02-09 22:50:19 +00:00
inp_non_block();
2012-02-09 23:15:53 +00:00
while(cmd_result == TRUE) {
2012-02-09 22:50:19 +00:00
int ch = ERR;
2012-02-20 01:42:29 +00:00
char inp[100];
2012-02-09 22:50:19 +00:00
int size = 0;
2012-03-01 01:52:35 +00:00
while(ch != '\n') {
gui_refresh();
jabber_process_events();
2012-03-10 20:46:30 +00:00
inp_get_char(&ch, inp, &size);
win_handle_special_keys(&ch);
2012-03-01 01:52:35 +00:00
}
2012-02-17 00:42:41 +00:00
2012-02-20 01:42:29 +00:00
inp[size++] = '\0';
cmd_result = process_input(inp);
2012-02-09 22:50:19 +00:00
}
}
2012-03-09 01:06:55 +00:00
void profanity_init(const int disable_tls)
2012-02-27 01:48:51 +00:00
{
2012-03-01 01:44:47 +00:00
log_init();
gui_init();
2012-02-27 01:48:51 +00:00
jabber_init(disable_tls);
history_init();
atexit(_profanity_shutdown);
2012-02-27 01:48:51 +00:00
}
void _profanity_shutdown(void)
2012-03-01 01:44:47 +00:00
{
jabber_disconnect();
gui_close();
log_close();
}