1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00
profanity/profanity.c

73 lines
1.6 KiB
C
Raw Normal View History

2012-02-20 15:07:38 -05: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 17:24:03 -05:00
#include <string.h>
#include <unistd.h>
#include <ncurses.h>
#include "profanity.h"
2012-02-05 10:10:10 -05:00
#include "log.h"
2012-02-05 18:08:15 -05:00
#include "windows.h"
2012-02-09 17:24:03 -05:00
#include "jabber.h"
2012-02-09 18:15:53 -05:00
#include "command.h"
2012-02-26 20:44:09 -05:00
#include "history.h"
2012-02-09 17:24:03 -05:00
2012-02-29 20:44:47 -05:00
void profanity_run(void)
2012-02-09 17:50:19 -05:00
{
2012-02-09 18:15:53 -05:00
int cmd_result = TRUE;
2012-02-09 17:50:19 -05:00
inp_non_block();
2012-02-09 18:15:53 -05:00
while(cmd_result == TRUE) {
2012-02-09 17:50:19 -05:00
int ch = ERR;
2012-02-19 20:42:29 -05:00
char inp[100];
2012-02-09 17:50:19 -05:00
int size = 0;
2012-02-29 20:52:35 -05:00
while(ch != '\n') {
usleep(1);
gui_refresh();
jabber_process_events();
win_handle_switch(&ch);
inp_poll_char(&ch, inp, &size);
}
2012-02-16 19:42:41 -05:00
2012-02-19 20:42:29 -05:00
inp[size++] = '\0';
cmd_result = process_input(inp);
2012-02-09 17:50:19 -05:00
}
}
2012-02-29 20:44:47 -05:00
void profanity_init(int disable_tls)
2012-02-26 20:48:51 -05:00
{
2012-02-29 20:44:47 -05:00
log_init();
gui_init();
2012-02-26 20:48:51 -05:00
jabber_init(disable_tls);
history_init();
}
2012-02-29 20:44:47 -05:00
void profanity_shutdown(void)
{
jabber_disconnect();
gui_close();
log_close();
}