mirror of
https://github.com/Tha14/toxic.git
synced 2025-04-19 12:12:58 +02:00
Merge pull request #33 from JFreegman/master
made error handling more consistent and added exit function
This commit is contained in:
commit
be425be976
39
src/chat.c
39
src/chat.c
@ -49,7 +49,7 @@ static void chat_onMessage(ToxWindow *self, Tox *m, int num, uint8_t *msg, uint1
|
|||||||
struct tm *timeinfo = get_time();
|
struct tm *timeinfo = get_time();
|
||||||
|
|
||||||
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
|
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
|
||||||
tox_getname(m, num, (uint8_t *) &nick);
|
tox_getname(m, num, nick);
|
||||||
|
|
||||||
wattron(ctx->history, COLOR_PAIR(CYAN));
|
wattron(ctx->history, COLOR_PAIR(CYAN));
|
||||||
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||||
@ -81,7 +81,7 @@ static void chat_onAction(ToxWindow *self, Tox *m, int num, uint8_t *action, uin
|
|||||||
struct tm *timeinfo = get_time();
|
struct tm *timeinfo = get_time();
|
||||||
|
|
||||||
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
|
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
|
||||||
tox_getname(m, num, (uint8_t *) &nick);
|
tox_getname(m, num, nick);
|
||||||
|
|
||||||
wattron(ctx->history, COLOR_PAIR(CYAN));
|
wattron(ctx->history, COLOR_PAIR(CYAN));
|
||||||
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||||
@ -133,7 +133,7 @@ int string_is_empty(char *string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* convert wide characters to null terminated string */
|
/* convert wide characters to null terminated string */
|
||||||
static char *wcs_to_char(wchar_t *string)
|
static uint8_t *wcs_to_char(wchar_t *string)
|
||||||
{
|
{
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
@ -142,12 +142,22 @@ static char *wcs_to_char(wchar_t *string)
|
|||||||
if (len != (size_t) -1) {
|
if (len != (size_t) -1) {
|
||||||
len++;
|
len++;
|
||||||
ret = malloc(len);
|
ret = malloc(len);
|
||||||
|
if (ret != NULL)
|
||||||
wcstombs(ret, string, len);
|
wcstombs(ret, string, len);
|
||||||
} else {
|
} else {
|
||||||
ret = malloc(2);
|
ret = malloc(2);
|
||||||
|
if (ret != NULL) {
|
||||||
ret[0] = ' ';
|
ret[0] = ' ';
|
||||||
ret[1] = '\0';
|
ret[1] = '\0';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == NULL) {
|
||||||
|
fprintf(stderr, "malloc() failed. Aborting...\n");
|
||||||
|
endwin();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,16 +213,12 @@ static void execute(ToxWindow *self, ChatContext *ctx, StatusBar *statusbar, Tox
|
|||||||
print_help(ctx);
|
print_help(ctx);
|
||||||
|
|
||||||
else if (!strcmp(cmd, "/quit") || !strcmp(cmd, "/exit") || !strcmp(cmd, "/q")) {
|
else if (!strcmp(cmd, "/quit") || !strcmp(cmd, "/exit") || !strcmp(cmd, "/q")) {
|
||||||
endwin();
|
exit_toxic(m);
|
||||||
store_data(m, DATA_FILE);
|
|
||||||
free(DATA_FILE);
|
|
||||||
tox_kill(m);
|
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strncmp(cmd, "/me ", strlen("/me "))) {
|
else if (!strncmp(cmd, "/me ", strlen("/me "))) {
|
||||||
struct tm *timeinfo = get_time();
|
struct tm *timeinfo = get_time();
|
||||||
char *action = strchr(cmd, ' ');
|
uint8_t *action = strchr(cmd, ' ');
|
||||||
|
|
||||||
if (action == NULL) {
|
if (action == NULL) {
|
||||||
wprintw(self->window, "Invalid syntax.\n");
|
wprintw(self->window, "Invalid syntax.\n");
|
||||||
@ -233,7 +239,7 @@ static void execute(ToxWindow *self, ChatContext *ctx, StatusBar *statusbar, Tox
|
|||||||
wattroff(ctx->history, COLOR_PAIR(YELLOW));
|
wattroff(ctx->history, COLOR_PAIR(YELLOW));
|
||||||
|
|
||||||
if (!statusbar->is_online
|
if (!statusbar->is_online
|
||||||
|| tox_sendaction(m, self->friendnum, (uint8_t *) action, strlen(action) + 1) == 0) {
|
|| tox_sendaction(m, self->friendnum, action, strlen(action) + 1) == 0) {
|
||||||
wattron(ctx->history, COLOR_PAIR(RED));
|
wattron(ctx->history, COLOR_PAIR(RED));
|
||||||
wprintw(ctx->history, " * Failed to send action\n");
|
wprintw(ctx->history, " * Failed to send action\n");
|
||||||
wattroff(ctx->history, COLOR_PAIR(RED));
|
wattroff(ctx->history, COLOR_PAIR(RED));
|
||||||
@ -373,7 +379,7 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key)
|
|||||||
|
|
||||||
/* RETURN key: Execute command or print line */
|
/* RETURN key: Execute command or print line */
|
||||||
else if (key == '\n') {
|
else if (key == '\n') {
|
||||||
char *line = wcs_to_char(ctx->line);
|
uint8_t *line = wcs_to_char(ctx->line);
|
||||||
wclear(ctx->linewin);
|
wclear(ctx->linewin);
|
||||||
wmove(self->window, y2 - CURS_Y_OFFSET, 0);
|
wmove(self->window, y2 - CURS_Y_OFFSET, 0);
|
||||||
wclrtobot(self->window);
|
wclrtobot(self->window);
|
||||||
@ -403,7 +409,7 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key)
|
|||||||
wprintw(ctx->history, "%s\n", line);
|
wprintw(ctx->history, "%s\n", line);
|
||||||
|
|
||||||
if (!statusbar->is_online
|
if (!statusbar->is_online
|
||||||
|| tox_sendmessage(m, self->friendnum, (uint8_t *) line, strlen(line) + 1) == 0) {
|
|| tox_sendmessage(m, self->friendnum, line, strlen(line) + 1) == 0) {
|
||||||
wattron(ctx->history, COLOR_PAIR(RED));
|
wattron(ctx->history, COLOR_PAIR(RED));
|
||||||
wprintw(ctx->history, " * Failed to send message.\n");
|
wprintw(ctx->history, " * Failed to send message.\n");
|
||||||
wattroff(ctx->history, COLOR_PAIR(RED));
|
wattroff(ctx->history, COLOR_PAIR(RED));
|
||||||
@ -532,13 +538,20 @@ ToxWindow new_chat(Tox *m, ToxWindow *prompt, int friendnum)
|
|||||||
ret.onAction = &chat_onAction;
|
ret.onAction = &chat_onAction;
|
||||||
|
|
||||||
uint8_t name[TOX_MAX_NAME_LENGTH] = {'\0'};
|
uint8_t name[TOX_MAX_NAME_LENGTH] = {'\0'};
|
||||||
tox_getname(m, friendnum, (uint8_t *) &name);
|
tox_getname(m, friendnum, name);
|
||||||
snprintf(ret.name, sizeof(ret.name), "%s", name);
|
snprintf(ret.name, sizeof(ret.name), "%s", name);
|
||||||
|
|
||||||
ChatContext *x = calloc(1, sizeof(ChatContext));
|
ChatContext *x = calloc(1, sizeof(ChatContext));
|
||||||
StatusBar *s = calloc(1, sizeof(StatusBar));
|
StatusBar *s = calloc(1, sizeof(StatusBar));
|
||||||
|
|
||||||
|
if (s != NULL && x != NULL) {
|
||||||
ret.x = x;
|
ret.x = x;
|
||||||
ret.s = s;
|
ret.s = s;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "calloc() failed. Aborting...\n");
|
||||||
|
endwin();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
ret.prompt = prompt;
|
ret.prompt = prompt;
|
||||||
ret.friendnum = friendnum;
|
ret.friendnum = friendnum;
|
||||||
|
@ -17,8 +17,6 @@
|
|||||||
#include "friendlist.h"
|
#include "friendlist.h"
|
||||||
|
|
||||||
extern char *DATA_FILE;
|
extern char *DATA_FILE;
|
||||||
extern int store_data(Tox *m, char *path);
|
|
||||||
|
|
||||||
extern ToxWindow *prompt;
|
extern ToxWindow *prompt;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -136,9 +134,10 @@ static void select_friend(Tox *m, wint_t key)
|
|||||||
} else return; /* Bad key input */
|
} else return; /* Bad key input */
|
||||||
|
|
||||||
/* If we reach this something is wrong */
|
/* If we reach this something is wrong */
|
||||||
|
fprintf(stderr, "select_friend() failed. Aborting...\n");
|
||||||
endwin();
|
endwin();
|
||||||
tox_kill(m);
|
tox_kill(m);
|
||||||
exit(2);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete_friend(Tox *m, ToxWindow *self, int f_num, wint_t key)
|
static void delete_friend(Tox *m, ToxWindow *self, int f_num, wint_t key)
|
||||||
|
51
src/main.c
51
src/main.c
@ -60,9 +60,9 @@ static void init_term()
|
|||||||
signal(SIGWINCH, on_window_resize);
|
signal(SIGWINCH, on_window_resize);
|
||||||
#if HAVE_WIDECHAR
|
#if HAVE_WIDECHAR
|
||||||
if (setlocale(LC_ALL, "") == NULL) {
|
if (setlocale(LC_ALL, "") == NULL) {
|
||||||
printf("Could not set your locale, plese check your locale settings or"
|
fprintf(stderr, "Could not set your locale, plese check your locale settings or"
|
||||||
"disable wide char support\n");
|
"disable wide char support\n");
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
initscr();
|
initscr();
|
||||||
@ -91,7 +91,7 @@ static Tox *init_tox()
|
|||||||
{
|
{
|
||||||
/* Init core */
|
/* Init core */
|
||||||
Tox *m = tox_new();
|
Tox *m = tox_new();
|
||||||
if (!m)
|
if (m == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Callbacks */
|
/* Callbacks */
|
||||||
@ -184,7 +184,7 @@ int init_connection(Tox *m)
|
|||||||
|
|
||||||
fp = fopen(SRVLIST_FILE, "r");
|
fp = fopen(SRVLIST_FILE, "r");
|
||||||
|
|
||||||
if (!fp)
|
if (fp == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
char servers[MAXSERVERS][MAXLINE];
|
char servers[MAXSERVERS][MAXLINE];
|
||||||
@ -208,7 +208,7 @@ int init_connection(Tox *m)
|
|||||||
char *port = strtok(NULL, " ");
|
char *port = strtok(NULL, " ");
|
||||||
char *key = strtok(NULL, " ");
|
char *key = strtok(NULL, " ");
|
||||||
|
|
||||||
if (!ip || !port || !key)
|
if (ip == NULL || port == NULL || key == NULL)
|
||||||
return 3;
|
return 3;
|
||||||
|
|
||||||
tox_IP_Port dht;
|
tox_IP_Port dht;
|
||||||
@ -317,18 +317,18 @@ static void load_data(Tox *m, char *path)
|
|||||||
buf = malloc(len);
|
buf = malloc(len);
|
||||||
|
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "malloc() failed.\n");
|
fprintf(stderr, "malloc() failed. Aborting...\n");
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
endwin();
|
endwin();
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fread(buf, len, 1, fd) != 1) {
|
if (fread(buf, len, 1, fd) != 1) {
|
||||||
fprintf(stderr, "fread() failed.\n");
|
fprintf(stderr, "fread() failed. Aborting...\n");
|
||||||
free(buf);
|
free(buf);
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
endwin();
|
endwin();
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
tox_load(m, buf, len);
|
tox_load(m, buf, len);
|
||||||
@ -349,11 +349,22 @@ static void load_data(Tox *m, char *path)
|
|||||||
if ((st = store_data(m, path)) != 0) {
|
if ((st = store_data(m, path)) != 0) {
|
||||||
fprintf(stderr, "Store messenger failed with return code: %d\n", st);
|
fprintf(stderr, "Store messenger failed with return code: %d\n", st);
|
||||||
endwin();
|
endwin();
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void exit_toxic(Tox *m)
|
||||||
|
{
|
||||||
|
store_data(m, DATA_FILE);
|
||||||
|
free(DATA_FILE);
|
||||||
|
free(SRVLIST_FILE);
|
||||||
|
free(prompt->s);
|
||||||
|
tox_kill(m);
|
||||||
|
endwin();
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *user_config_dir = get_user_config_dir();
|
char *user_config_dir = get_user_config_dir();
|
||||||
@ -386,17 +397,20 @@ int main(int argc, char *argv[])
|
|||||||
SRVLIST_FILE = strdup(PACKAGE_DATADIR "/DHTservers");
|
SRVLIST_FILE = strdup(PACKAGE_DATADIR "/DHTservers");
|
||||||
} else {
|
} else {
|
||||||
DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1);
|
DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1);
|
||||||
if (DATA_FILE != NULL) {
|
SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTservers") + 1);
|
||||||
|
|
||||||
|
if (DATA_FILE != NULL && SRVLIST_FILE != NULL) {
|
||||||
strcpy(DATA_FILE, user_config_dir);
|
strcpy(DATA_FILE, user_config_dir);
|
||||||
strcat(DATA_FILE, CONFIGDIR);
|
strcat(DATA_FILE, CONFIGDIR);
|
||||||
strcat(DATA_FILE, "data");
|
strcat(DATA_FILE, "data");
|
||||||
}
|
|
||||||
|
|
||||||
SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTservers") + 1);
|
|
||||||
if (SRVLIST_FILE != NULL) {
|
|
||||||
strcpy(SRVLIST_FILE, user_config_dir);
|
strcpy(SRVLIST_FILE, user_config_dir);
|
||||||
strcat(SRVLIST_FILE, CONFIGDIR);
|
strcat(SRVLIST_FILE, CONFIGDIR);
|
||||||
strcat(SRVLIST_FILE, "DHTservers");
|
strcat(SRVLIST_FILE, "DHTservers");
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "malloc() failed. Aborting...\n");
|
||||||
|
endwin();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -405,10 +419,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
init_term();
|
init_term();
|
||||||
Tox *m = init_tox();
|
Tox *m = init_tox();
|
||||||
if (!m) {
|
|
||||||
|
if (m == NULL) {
|
||||||
endwin();
|
endwin();
|
||||||
fprintf(stderr, "Failed to initialize network. Aborting...\n");
|
fprintf(stderr, "Failed to initialize network. Aborting...\n");
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt = init_windows(m);
|
prompt = init_windows(m);
|
||||||
@ -440,8 +455,6 @@ int main(int argc, char *argv[])
|
|||||||
draw_active_window(m);
|
draw_active_window(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
tox_kill(m);
|
exit_toxic(m);
|
||||||
free(DATA_FILE);
|
|
||||||
free(SRVLIST_FILE);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
22
src/prompt.c
22
src/prompt.c
@ -10,11 +10,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "toxic_windows.h"
|
|
||||||
#include "prompt.h"
|
#include "prompt.h"
|
||||||
|
|
||||||
extern char *DATA_FILE;
|
extern char *DATA_FILE;
|
||||||
extern int store_data(Tox *m, char *path);
|
|
||||||
|
|
||||||
uint8_t pending_requests[MAX_STR_SIZE][TOX_CLIENT_ID_SIZE]; // XXX
|
uint8_t pending_requests[MAX_STR_SIZE][TOX_CLIENT_ID_SIZE]; // XXX
|
||||||
uint8_t num_requests = 0; // XXX
|
uint8_t num_requests = 0; // XXX
|
||||||
@ -115,6 +113,13 @@ unsigned char *hex_string_to_bin(char hex_string[])
|
|||||||
{
|
{
|
||||||
size_t len = strlen(hex_string);
|
size_t len = strlen(hex_string);
|
||||||
unsigned char *val = malloc(len);
|
unsigned char *val = malloc(len);
|
||||||
|
|
||||||
|
if (val == NULL) {
|
||||||
|
fprintf(stderr, "malloc() failed. Aborting...\n");
|
||||||
|
endwin();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
char *pos = hex_string;
|
char *pos = hex_string;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -294,11 +299,7 @@ void cmd_connect(ToxWindow *self, Tox *m, int argc, char **argv)
|
|||||||
|
|
||||||
void cmd_quit(ToxWindow *self, Tox *m, int argc, char **argv)
|
void cmd_quit(ToxWindow *self, Tox *m, int argc, char **argv)
|
||||||
{
|
{
|
||||||
endwin();
|
exit_toxic(m);
|
||||||
store_data(m, DATA_FILE);
|
|
||||||
free(DATA_FILE);
|
|
||||||
tox_kill(m);
|
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_help(ToxWindow *self, Tox *m, int argc, char **argv)
|
void cmd_help(ToxWindow *self, Tox *m, int argc, char **argv)
|
||||||
@ -694,7 +695,14 @@ ToxWindow new_prompt()
|
|||||||
strcpy(ret.name, "prompt");
|
strcpy(ret.name, "prompt");
|
||||||
|
|
||||||
StatusBar *s = calloc(1, sizeof(StatusBar));
|
StatusBar *s = calloc(1, sizeof(StatusBar));
|
||||||
|
|
||||||
|
if (s != NULL)
|
||||||
ret.s = s;
|
ret.s = s;
|
||||||
|
else {
|
||||||
|
fprintf(stderr, "calloc() failed. Aborting...\n");
|
||||||
|
endwin();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -9,5 +9,3 @@ unsigned char *hex_string_to_bin(char hex_string[]);
|
|||||||
void prompt_init_statusbar(ToxWindow *self, Tox *m);
|
void prompt_init_statusbar(ToxWindow *self, Tox *m);
|
||||||
|
|
||||||
#endif /* end of include guard: PROMPT_H_UZYGWFFL */
|
#endif /* end of include guard: PROMPT_H_UZYGWFFL */
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,9 @@
|
|||||||
|
|
||||||
#define UNKNOWN_NAME "Unknown"
|
#define UNKNOWN_NAME "Unknown"
|
||||||
|
|
||||||
|
#define EXIT_SUCCESS 0
|
||||||
|
#define EXIT_FAILURE 1
|
||||||
|
|
||||||
#ifndef TOXICVER
|
#ifndef TOXICVER
|
||||||
#define TOXICVER "NOVER" //Use the -D flag to set this
|
#define TOXICVER "NOVER" //Use the -D flag to set this
|
||||||
#endif
|
#endif
|
||||||
@ -85,4 +88,3 @@ int add_window(Tox *m, ToxWindow w);
|
|||||||
void del_window(ToxWindow *w);
|
void del_window(ToxWindow *w);
|
||||||
void set_active_window(int ch);
|
void set_active_window(int ch);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include "toxic_windows.h"
|
#include "toxic_windows.h"
|
||||||
|
|
||||||
extern char *DATA_FILE;
|
extern char *DATA_FILE;
|
||||||
extern int store_data(Tox *m, char *path);
|
|
||||||
|
|
||||||
static ToxWindow windows[MAX_WINDOWS_NUM];
|
static ToxWindow windows[MAX_WINDOWS_NUM];
|
||||||
static ToxWindow *active_window;
|
static ToxWindow *active_window;
|
||||||
@ -31,7 +30,7 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userd
|
|||||||
void on_connectionchange(Tox *m, int friendnumber, uint8_t status, void *userdata)
|
void on_connectionchange(Tox *m, int friendnumber, uint8_t status, void *userdata)
|
||||||
{
|
{
|
||||||
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
|
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
|
||||||
tox_getname(m, friendnumber, (uint8_t *) &nick);
|
tox_getname(m, friendnumber, nick);
|
||||||
|
|
||||||
if (!nick[0])
|
if (!nick[0])
|
||||||
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
|
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
|
||||||
@ -177,7 +176,8 @@ void set_next_window(int ch)
|
|||||||
|
|
||||||
if (active_window == inf) { // infinite loop check
|
if (active_window == inf) { // infinite loop check
|
||||||
endwin();
|
endwin();
|
||||||
exit(2);
|
fprintf(stderr, "set_next_window() failed. Aborting...\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -195,9 +195,9 @@ ToxWindow *init_windows()
|
|||||||
int n_prompt = add_window(m, new_prompt());
|
int n_prompt = add_window(m, new_prompt());
|
||||||
|
|
||||||
if (n_prompt == -1 || add_window(m, new_friendlist()) == -1) {
|
if (n_prompt == -1 || add_window(m, new_friendlist()) == -1) {
|
||||||
fprintf(stderr, "add_window() failed.\n");
|
fprintf(stderr, "add_window() failed. Aborting...\n");
|
||||||
endwin();
|
endwin();
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt = &windows[n_prompt];
|
prompt = &windows[n_prompt];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user