1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-13 02:13:02 +01:00

use char instead of uint8_t, fix compiler warnings so toxic compiles with -Wall and -Werror on gcc and clang

This commit is contained in:
Jfreegman 2014-07-06 22:15:35 -04:00
parent 2ed9448b41
commit a009fbf20c
29 changed files with 369 additions and 368 deletions

View File

@ -15,7 +15,7 @@ MANFILES = toxic.1 toxic.conf.5
LIBS = libtoxcore ncursesw
CFLAGS = -std=gnu99 -pthread -Wimplicit-function-declaration -Wreturn-type -O1
CFLAGS = -std=gnu99 -pthread -Wall -Werror
CFLAGS += -DTOXICVER="\"$(VERSION)\"" -DHAVE_WIDECHAR -D_XOPEN_SOURCE_EXTENDED
CFLAGS += -DPACKAGE_DATADIR="\"$(abspath $(DATADIR))\""
CFLAGS += $(USER_CFLAGS)

View File

@ -52,7 +52,7 @@
typedef struct _Call {
pthread_t ttid; /* Transmission thread id */
_Bool ttas, has_output; /* Transmission thread active status (0 - stopped, 1- running) */
int in_idx, out_idx;
uint32_t in_idx, out_idx;
pthread_mutex_t mutex;
} Call;
@ -96,7 +96,7 @@ void callback_peer_timeout ( int32_t call_index, void *arg );
int stop_transmission(int call_index);
static void print_err (ToxWindow *self, uint8_t *error_str)
static void print_err (ToxWindow *self, char *error_str)
{
line_info_add(self, NULL, NULL, NULL, error_str, SYS_MSG, 0, 0);
}
@ -225,14 +225,14 @@ void *transmission(void *arg)
usleep(1000);
}
cleanup:
/* cleanup:
if ( this_call->in_idx != -1 ) if ( close_device(input, this_call->in_idx) != de_None )
line_info_add(self, NULL, NULL, NULL, "Failed to close input device!", SYS_MSG, 0, 0);
if ( this_call->out_idx != -1 ) if ( close_device(output, this_call->out_idx) != de_None )
line_info_add(self, NULL, NULL, NULL, "Failed to close output device!", SYS_MSG, 0, 0);
set_call(this_call, _False);
set_call(this_call, _False); */
_cbend;
}
@ -370,8 +370,8 @@ void callback_peer_timeout ( int32_t call_index, void* arg )
*/
void cmd_call(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t msg[MAX_STR_SIZE];
uint8_t *error_str;
char msg[MAX_STR_SIZE];
char *error_str;
if (argc != 0) {
error_str = "Invalid syntax!";
@ -408,7 +408,7 @@ on_error:
void cmd_answer(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *error_str;
char *error_str;
if (argc != 0) {
error_str = "Invalid syntax!";
@ -439,7 +439,7 @@ on_error:
void cmd_reject(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *error_str;
char *error_str;
if (argc != 0) {
error_str = "Invalid syntax!";
@ -470,7 +470,7 @@ on_error:
void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *error_str;
char *error_str;
if (argc != 0) {
error_str = "Invalid syntax!";
@ -499,7 +499,7 @@ on_error:
void cmd_cancel(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *error_str;
char *error_str;
if (argc != 0) {
error_str = "Invalid syntax!";
@ -532,8 +532,8 @@ on_error:
void cmd_list_devices(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t msg[MAX_STR_SIZE];
uint8_t *error_str;
char msg[MAX_STR_SIZE];
char *error_str;
if ( argc != 1 ) {
if ( argc < 1 ) error_str = "Type must be specified!";
@ -566,8 +566,8 @@ on_error:
/* This changes primary device only */
void cmd_change_device(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t msg[MAX_STR_SIZE];
uint8_t *error_str;
char msg[MAX_STR_SIZE];
char *error_str;
if ( argc != 2 ) {
if ( argc < 1 ) error_str = "Type must be specified!";
@ -612,8 +612,8 @@ on_error:
void cmd_ccur_device(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t msg[MAX_STR_SIZE];
uint8_t *error_str;
char msg[MAX_STR_SIZE];
char *error_str;
if ( argc != 2 ) {
if ( argc < 1 ) error_str = "Type must be specified!";
@ -681,8 +681,8 @@ void cmd_ccur_device(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (
void cmd_mute(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t msg[MAX_STR_SIZE];
uint8_t *error_str;
char msg[MAX_STR_SIZE];
char *error_str;
if ( argc != 1 ) {
if ( argc < 1 ) error_str = "Type must be specified!";
@ -728,9 +728,8 @@ void cmd_mute(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (*argv)[
}
void cmd_sense(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t msg[MAX_STR_SIZE];
uint8_t *error_str;
{
char *error_str;
if ( argc != 1 ) {
if ( argc < 1 ) error_str = "Must have value!";

View File

@ -62,7 +62,7 @@ static void kill_infobox(ToxWindow *self);
#endif /* _SUPPORT_AUDIO */
/* Array of chat command names used for tab completion. */
static const uint8_t chat_cmd_list[AC_NUM_CHAT_COMMANDS][MAX_CMDNAME_SIZE] = {
static const char chat_cmd_list[AC_NUM_CHAT_COMMANDS][MAX_CMDNAME_SIZE] = {
{ "/accept" },
{ "/add" },
{ "/clear" },
@ -138,24 +138,22 @@ void kill_chat_window(ToxWindow *self, Tox *m)
del_window(self);
}
static void chat_onMessage(ToxWindow *self, Tox *m, int32_t num, const uint8_t *msg, uint16_t len)
static void chat_onMessage(ToxWindow *self, Tox *m, int32_t num, const char *msg, uint16_t len)
{
if (self->num != num)
return;
ChatContext *ctx = self->chatwin;
uint8_t nick[TOX_MAX_NAME_LENGTH];
int n_len = tox_get_name(m, num, nick);
char nick[TOX_MAX_NAME_LENGTH];
int n_len = tox_get_name(m, num, (uint8_t *) nick);
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH - 1);
nick[n_len] = '\0';
uint8_t timefrmt[TIME_STR_SIZE];
char timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt, sizeof(timefrmt));
line_info_add(self, timefrmt, nick, NULL, msg, IN_MSG, 0, 0);
write_to_log(msg, nick, ctx->log, false);
alert_window(self, WINDOW_ALERT_1, true);
}
@ -184,20 +182,20 @@ static void chat_onTypingChange(ToxWindow *self, Tox *m, int32_t num, uint8_t is
friends[num].is_typing = is_typing;
}
static void chat_onAction(ToxWindow *self, Tox *m, int32_t num, const uint8_t *action, uint16_t len)
static void chat_onAction(ToxWindow *self, Tox *m, int32_t num, const char *action, uint16_t len)
{
if (self->num != num)
return;
ChatContext *ctx = self->chatwin;
uint8_t nick[TOX_MAX_NAME_LENGTH];
int n_len = tox_get_name(m, num, nick);
char nick[TOX_MAX_NAME_LENGTH];
int n_len = tox_get_name(m, num, (uint8_t *) nick);
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH - 1);;
nick[n_len] = '\0';
uint8_t timefrmt[TIME_STR_SIZE];
char timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt, sizeof(timefrmt));
line_info_add(self, timefrmt, nick, NULL, action, ACTION, 0, 0);
@ -205,7 +203,7 @@ static void chat_onAction(ToxWindow *self, Tox *m, int32_t num, const uint8_t *a
alert_window(self, WINDOW_ALERT_1, true);
}
static void chat_onNickChange(ToxWindow *self, Tox *m, int32_t num, const uint8_t *nick, uint16_t len)
static void chat_onNickChange(ToxWindow *self, Tox *m, int32_t num, const char *nick, uint16_t len)
{
if (self->num != num)
return;
@ -222,7 +220,7 @@ static void chat_onStatusChange(ToxWindow *self, Tox *m, int32_t num, uint8_t st
statusbar->status = status;
}
static void chat_onStatusMessageChange(ToxWindow *self, int32_t num, const uint8_t *status, uint16_t len)
static void chat_onStatusMessageChange(ToxWindow *self, int32_t num, const char *status, uint16_t len)
{
if (self->num != num)
return;
@ -234,19 +232,19 @@ static void chat_onStatusMessageChange(ToxWindow *self, int32_t num, const uint8
}
static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, uint8_t filenum,
uint64_t filesize, const uint8_t *pathname, uint16_t path_len)
uint64_t filesize, const char *pathname, uint16_t path_len)
{
if (self->num != num)
return;
uint8_t msg[MAX_STR_SIZE * 2];
uint8_t *errmsg;
char msg[MAX_STR_SIZE * 2];
char *errmsg;
/* holds the filename appended to the user specified path */
uint8_t filename_path[MAX_STR_SIZE] = {0};
char filename_path[MAX_STR_SIZE] = {0};
/* holds the lone filename */
uint8_t filename_nopath[MAX_STR_SIZE];
char filename_nopath[MAX_STR_SIZE];
get_file_name(filename_nopath, pathname);
int len = strlen(filename_nopath);
@ -272,7 +270,7 @@ static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, uint8_t
return;
}
uint8_t filename[MAX_STR_SIZE];
char filename[MAX_STR_SIZE];
if (filename_path[0])
strcpy(filename, filename_path);
@ -325,14 +323,14 @@ static void chat_close_file_receiver(int32_t num, uint8_t filenum)
}
static void chat_onFileControl(ToxWindow *self, Tox *m, int32_t num, uint8_t receive_send,
uint8_t filenum, uint8_t control_type, const uint8_t *data, uint16_t length)
uint8_t filenum, uint8_t control_type, const char *data, uint16_t length)
{
if (self->num != num)
return;
const uint8_t *filename;
uint8_t msg[MAX_STR_SIZE] = {0};
int i; /* file_sender index */
const char *filename;
char msg[MAX_STR_SIZE] = {0};
int i = 0; /* file_sender index */
if (receive_send == 0) {
filename = friends[num].file_receiver.filenames[filenum];
@ -375,7 +373,7 @@ static void chat_onFileControl(ToxWindow *self, Tox *m, int32_t num, uint8_t rec
alert_window(self, WINDOW_ALERT_2, true);
}
static void chat_onFileData(ToxWindow *self, Tox *m, int32_t num, uint8_t filenum, const uint8_t *data,
static void chat_onFileData(ToxWindow *self, Tox *m, int32_t num, uint8_t filenum, const char *data,
uint16_t length)
{
if (self->num != num)
@ -400,22 +398,21 @@ static void chat_onFileData(ToxWindow *self, Tox *m, int32_t num, uint8_t filenu
uint64_t size = friends[num].file_receiver.size[filenum];
long double pct_remain = remain ? (1 - (remain / size)) * 100 : 100;
uint8_t msg[MAX_STR_SIZE];
const uint8_t *name = friends[num].file_receiver.filenames[filenum];
char msg[MAX_STR_SIZE];
const char *name = friends[num].file_receiver.filenames[filenum];
snprintf(msg, sizeof(msg), "Saving file as: '%s' (%.1Lf%%)", name, pct_remain);
line_info_set(self, friends[num].file_receiver.line_id[filenum], msg);
}
}
static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, const uint8_t *group_pub_key)
static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, const char *group_pub_key)
{
if (self->num != friendnumber)
return;
uint8_t name[TOX_MAX_NAME_LENGTH];
uint8_t msg[MAX_STR_SIZE + TOX_MAX_NAME_LENGTH];
int n_len = tox_get_name(m, friendnumber, name);
char name[TOX_MAX_NAME_LENGTH];
char msg[MAX_STR_SIZE + TOX_MAX_NAME_LENGTH];
int n_len = tox_get_name(m, friendnumber, (uint8_t *) name);
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH - 1);
name[n_len] = '\0';
@ -423,7 +420,8 @@ static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, co
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
line_info_add(self, NULL, NULL, NULL, "Type \"/join\" to join the chat.", SYS_MSG, 0, 0);
memcpy(friends[friendnumber].groupchat_key, group_pub_key, TOX_CLIENT_ID_SIZE);
memcpy(friends[friendnumber].groupchat_key, group_pub_key,
sizeof(friends[friendnumber].groupchat_key));
friends[friendnumber].groupchat_pending = true;
alert_window(self, WINDOW_ALERT_2, true);
@ -440,9 +438,7 @@ void chat_onInvite (ToxWindow *self, ToxAv *av, int call_index)
/* call_index is set here and reset on call end */
self->call_idx = call_index;
line_info_add(self, NULL, NULL, NULL, "Incoming audio call! Type: \"/answer\" or \"/reject\"", SYS_MSG, 0, 0);
alert_window(self, WINDOW_ALERT_0, true);
}
@ -547,6 +543,7 @@ static void init_infobox(ToxWindow *self)
int x2, y2;
getmaxyx(self->window, y2, x2);
(void) y2;
memset(&ctx->infobox, 0, sizeof(struct infobox));
@ -624,22 +621,22 @@ static void draw_infobox(ToxWindow *self)
#endif /* _SUPPORT_AUDIO */
static void send_action(ToxWindow *self, ChatContext *ctx, Tox *m, uint8_t *action)
static void send_action(ToxWindow *self, ChatContext *ctx, Tox *m, char *action)
{
if (action == NULL)
return;
uint8_t selfname[TOX_MAX_NAME_LENGTH];
uint16_t len = tox_get_self_name(m, selfname);
char selfname[TOX_MAX_NAME_LENGTH];
uint16_t len = tox_get_self_name(m, (uint8_t *) selfname);
selfname[len] = '\0';
uint8_t timefrmt[TIME_STR_SIZE];
char timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt, sizeof(timefrmt));
line_info_add(self, timefrmt, selfname, NULL, action, ACTION, 0, 0);
if (tox_send_action(m, self->num, action, strlen(action)) == 0) {
uint8_t *errmsg = " * Failed to send action.";
if (tox_send_action(m, self->num, (uint8_t *) action, strlen(action)) == 0) {
char *errmsg = " * Failed to send action.";
line_info_add(self, NULL, selfname, NULL, errmsg, SYS_MSG, 0, RED);
} else {
write_to_log(action, selfname, ctx->log, true);
@ -694,7 +691,7 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
} else if (key == '\n') {
rm_trailing_spaces_buf(ctx);
uint8_t line[MAX_STR_SIZE];
char line[MAX_STR_SIZE];
if (wcs_to_mbs_buf(line, ctx->line, MAX_STR_SIZE) == -1)
memset(&line, 0, sizeof(line));
@ -712,17 +709,17 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
execute(ctx->history, self, m, line, CHAT_COMMAND_MODE);
}
} else if (!string_is_empty(line)) {
uint8_t selfname[TOX_MAX_NAME_LENGTH];
uint16_t len = tox_get_self_name(m, selfname);
char selfname[TOX_MAX_NAME_LENGTH];
uint16_t len = tox_get_self_name(m, (uint8_t *) selfname);
selfname[len] = '\0';
uint8_t timefrmt[TIME_STR_SIZE];
char timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt, sizeof(timefrmt));
line_info_add(self, timefrmt, selfname, NULL, line, OUT_MSG, 0, 0);
if (!statusbar->is_online || tox_send_message(m, self->num, line, strlen(line)) == 0) {
uint8_t *errmsg = " * Failed to send message.";
if (!statusbar->is_online || tox_send_message(m, self->num, (uint8_t *) line, strlen(line)) == 0) {
char *errmsg = " * Failed to send message.";
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, RED);
} else {
write_to_log(line, selfname, ctx->log, false);
@ -803,10 +800,10 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
/* Reset statusbar->statusmsg on window resize */
if (x2 != self->x) {
uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH] = {'\0'};
char statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH] = {'\0'};
pthread_mutex_lock(&Winthread.lock);
tox_get_status_message(m, self->num, statusmsg, TOX_MAX_STATUSMESSAGE_LENGTH);
tox_get_status_message(m, self->num, (uint8_t *) statusmsg, TOX_MAX_STATUSMESSAGE_LENGTH);
pthread_mutex_unlock(&Winthread.lock);
snprintf(statusbar->statusmsg, sizeof(statusbar->statusmsg), "%s", statusmsg);
@ -841,6 +838,7 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
int y, x;
getyx(self->window, y, x);
(void) x;
int new_x = ctx->start ? x2 - 1 : ctx->pos;
wmove(self->window, y + 1, new_x);
@ -870,8 +868,8 @@ static void chat_onInit(ToxWindow *self, Tox *m)
statusbar->status = tox_get_user_status(m, self->num);
statusbar->is_online = tox_get_friend_connection_status(m, self->num) == 1;
uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH] = {'\0'};
uint16_t s_len = tox_get_status_message(m, self->num, statusmsg, TOX_MAX_STATUSMESSAGE_LENGTH);
char statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH] = {'\0'};
uint16_t s_len = tox_get_status_message(m, self->num, (uint8_t *) statusmsg, TOX_MAX_STATUSMESSAGE_LENGTH);
statusmsg[s_len] = '\0';
snprintf(statusbar->statusmsg, sizeof(statusbar->statusmsg), "%s", statusmsg);
statusbar->statusmsg_len = s_len;
@ -940,13 +938,9 @@ ToxWindow new_chat(Tox *m, int32_t friendnum)
ret.device_selection[0] = ret.device_selection[1] = -1;
#endif /* _SUPPORT_AUDIO */
uint8_t name[TOX_MAX_NAME_LENGTH] = {'\0'};
int len = tox_get_name(m, friendnum, name);
len = MIN(len, TOXIC_MAX_NAME_LENGTH - 1);
name[len] = '\0';
strcpy(ret.name, name);
char name[TOX_MAX_NAME_LENGTH] = {'\0'};
tox_get_name(m, friendnum, (uint8_t *) name);
snprintf(ret.name, sizeof(ret.name), "%s", name);
ChatContext *chatwin = calloc(1, sizeof(ChatContext));
StatusBar *stb = calloc(1, sizeof(StatusBar));

View File

@ -40,7 +40,7 @@ extern uint8_t max_file_senders_index;
void cmd_groupinvite(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *errmsg;
char *errmsg;
if (argc < 1) {
errmsg = "Invalid syntax";
@ -62,14 +62,14 @@ void cmd_groupinvite(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*a
return;
}
uint8_t msg[MAX_STR_SIZE];
char msg[MAX_STR_SIZE];
snprintf(msg, sizeof(msg), "Invited friend to Room #%d.", groupnum);
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
}
void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *errmsg;
char *errmsg;
if (get_num_active_windows() >= MAX_WINDOWS_NUM) {
errmsg = " * Warning: Too many windows are open.";
@ -77,7 +77,7 @@ void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*ar
return;
}
uint8_t *groupkey = friends[self->num].groupchat_key;
char *groupkey = friends[self->num].groupchat_key;
if (!friends[self->num].groupchat_pending) {
errmsg = "No pending group chat invite.";
@ -85,7 +85,7 @@ void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*ar
return;
}
int groupnum = tox_join_groupchat(m, self->num, groupkey);
int groupnum = tox_join_groupchat(m, self->num, (uint8_t *) groupkey);
if (groupnum == -1) {
errmsg = "Group chat instance failed to initialize.";
@ -103,7 +103,7 @@ void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*ar
void cmd_savefile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *errmsg;
char *errmsg;
if (argc != 1) {
errmsg = "Invalid syntax.";
@ -125,10 +125,10 @@ void cmd_savefile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
return;
}
uint8_t *filename = friends[self->num].file_receiver.filenames[filenum];
char *filename = friends[self->num].file_receiver.filenames[filenum];
if (tox_file_send_control(m, self->num, 1, filenum, TOX_FILECONTROL_ACCEPT, 0, 0) == 0) {
uint8_t msg[MAX_STR_SIZE];
char msg[MAX_STR_SIZE];
snprintf(msg, sizeof(msg), "Saving file as: '%s' (%.1f%%)", filename, 0.0);
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
friends[self->num].file_receiver.line_id[filenum] = self->chatwin->hst->line_end->id + 1;
@ -148,7 +148,7 @@ void cmd_savefile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *errmsg;
char *errmsg;
if (max_file_senders_index >= (MAX_FILES - 1)) {
errmsg = "Please wait for some of your outgoing file transfers to complete.";
@ -162,7 +162,7 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
return;
}
uint8_t *path = argv[1];
char *path = argv[1];
if (path[0] != '\"') {
errmsg = "File path must be enclosed in quotes.";
@ -170,7 +170,8 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
return;
}
path[strlen(++path) - 1] = L'\0';
++path;
path[strlen(path) - 1] = L'\0';
int path_len = strlen(path);
if (path_len > MAX_STR_SIZE) {
@ -191,9 +192,9 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
uint64_t filesize = ftell(file_to_send);
fseek(file_to_send, 0, SEEK_SET);
uint8_t filename[MAX_STR_SIZE];
char filename[MAX_STR_SIZE];
get_file_name(filename, path);
int filenum = tox_new_file_sender(m, self->num, filesize, filename, strlen(filename));
int filenum = tox_new_file_sender(m, self->num, filesize, (const uint8_t *) filename, strlen(filename));
if (filenum == -1) {
errmsg = "Error sending file.";
@ -216,7 +217,7 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
file_senders[i].piecelen = fread(file_senders[i].nextpiece, 1,
tox_file_data_size(m, self->num), file_to_send);
uint8_t msg[MAX_STR_SIZE];
char msg[MAX_STR_SIZE];
snprintf(msg, sizeof(msg), "Sending file: '%s'", path);
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);

View File

@ -62,8 +62,8 @@ typedef struct _Device {
const char *ddevice_names[2]; /* Default device */
const char *devices_names[2][MAX_DEVICES]; /* Container of available devices */
static int size[2]; /* Size of above containers */
Device *running[2][MAX_DEVICES]={NULL}; /* Running devices */
uint32_t primary_device[2] = {0}; /* Primary device */
Device *running[2][MAX_DEVICES]; /* Running devices */
uint32_t primary_device[2]; /* Primary device */
static ToxAv* av = NULL;
@ -116,7 +116,7 @@ DeviceError init_devices(ToxAv* av_)
av = av_;
return ae_None;
return (DeviceError) ae_None;
}
DeviceError terminate_devices()
@ -127,7 +127,7 @@ DeviceError terminate_devices()
pthread_mutex_destroy(&mutex);
return ae_None;
return (DeviceError) ae_None;
}
DeviceError device_mute(DeviceType type, uint32_t device_idx)
@ -419,7 +419,7 @@ void print_devices(ToxWindow* self, DeviceType type)
{
int i = 0;
for ( ; i < size[type]; i ++) {
uint8_t msg[MAX_STR_SIZE];
char msg[MAX_STR_SIZE];
snprintf(msg, sizeof(msg), "%d: %s", i, devices_names[type][i]);
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
}

View File

@ -82,4 +82,4 @@ DeviceError write_out(uint32_t device_idx, int16_t* data, uint32_t lenght, uint8
void print_devices(ToxWindow* self, DeviceType type);
DeviceError selection_valid(DeviceType type, int32_t selection);
#endif /* _device_h */
#endif /* _device_h */

View File

@ -47,8 +47,8 @@
/* TODO: process keys from key file instead of hard-coding like a noob */
static struct dns3_server {
uint8_t *name;
uint8_t key[DNS3_KEY_SZ];
char *name;
char key[DNS3_KEY_SZ];
} dns3_servers[] = {
{
"utox.org",
@ -68,9 +68,9 @@ static struct dns3_server {
static struct _thread_data {
ToxWindow *self;
uint8_t id_bin[TOX_FRIEND_ADDRESS_SIZE];
uint8_t addr[MAX_STR_SIZE];
uint8_t msg[MAX_STR_SIZE];
char id_bin[TOX_FRIEND_ADDRESS_SIZE];
char addr[MAX_STR_SIZE];
char msg[MAX_STR_SIZE];
uint8_t busy;
Tox *m;
} t_data;
@ -81,9 +81,9 @@ static struct _dns_thread {
} dns_thread;
static int dns_error(ToxWindow *self, uint8_t *errmsg)
static int dns_error(ToxWindow *self, char *errmsg)
{
uint8_t msg[MAX_STR_SIZE];
char msg[MAX_STR_SIZE];
snprintf(msg, sizeof(msg), "User lookup failed: %s", errmsg);
pthread_mutex_lock(&dns_thread.lock);
@ -103,11 +103,11 @@ static void kill_dns_thread(void *dns_obj)
}
/* puts TXT from dns response in buf. Returns length of TXT on success, -1 on fail.*/
static int parse_dns_response(ToxWindow *self, u_char *answer, int ans_len, uint8_t *buf)
static int parse_dns_response(ToxWindow *self, u_char *answer, int ans_len, char *buf)
{
uint8_t *ans_pt = answer + sizeof(HEADER);
uint8_t *ans_end = answer + ans_len;
uint8_t exp_ans[PACKETSZ];
char exp_ans[PACKETSZ];
int len = dn_expand(answer, ans_end, ans_pt, exp_ans, sizeof(exp_ans));
@ -171,10 +171,10 @@ static int parse_dns_response(ToxWindow *self, u_char *answer, int ans_len, uint
and the domain in dombuf.
return length of username on success, -1 on failure */
static int parse_addr(uint8_t *addr, uint8_t *namebuf, uint8_t *dombuf)
static int parse_addr(char *addr, char *namebuf, char *dombuf)
{
uint8_t tmpaddr[MAX_STR_SIZE];
uint8_t *tmpname, *tmpdom;
char tmpaddr[MAX_STR_SIZE];
char *tmpname, *tmpdom;
strcpy(tmpaddr, addr);
tmpname = strtok(tmpaddr, "@");
@ -195,8 +195,8 @@ void *dns3_lookup_thread(void *data)
{
ToxWindow *self = t_data.self;
uint8_t domain[MAX_STR_SIZE];
uint8_t name[MAX_STR_SIZE];
char domain[MAX_STR_SIZE];
char name[MAX_STR_SIZE];
int namelen = parse_addr(t_data.addr, name, domain);
@ -206,7 +206,8 @@ void *dns3_lookup_thread(void *data)
}
/* get domain name/pub key */
uint8_t *DNS_pubkey, *domname = NULL;
char *DNS_pubkey = NULL;
char *domname = NULL;
int i;
for (i = 0; i < NUM_DNS3_SERVERS; ++i) {
@ -222,17 +223,18 @@ void *dns3_lookup_thread(void *data)
kill_dns_thread(NULL);
}
void *dns_obj = tox_dns3_new(DNS_pubkey);
void *dns_obj = tox_dns3_new((uint8_t *) DNS_pubkey);
if (dns_obj == NULL) {
dns_error(self, "Core failed to create DNS object.");
kill_dns_thread(NULL);
}
uint8_t string[MAX_DNS_REQST_SIZE];
char string[MAX_DNS_REQST_SIZE];
uint32_t request_id;
int str_len = tox_generate_dns3_string(dns_obj, string, sizeof(string), &request_id, name, namelen);
int str_len = tox_generate_dns3_string(dns_obj, (uint8_t *) string, sizeof(string), &request_id,
(uint8_t *) name, namelen);
if (str_len == -1) {
dns_error(self, "Core failed to generate DNS3 string.");
@ -242,7 +244,7 @@ void *dns3_lookup_thread(void *data)
string[str_len] = '\0';
u_char answer[PACKETSZ];
uint8_t d_string[MAX_DNS_REQST_SIZE];
char d_string[MAX_DNS_REQST_SIZE];
/* format string and create dns query */
snprintf(d_string, sizeof(d_string), "_%s._tox.%s", string, domname);
@ -253,13 +255,13 @@ void *dns3_lookup_thread(void *data)
kill_dns_thread(dns_obj);
}
uint8_t ans_id[MAX_DNS_REQST_SIZE];
char ans_id[MAX_DNS_REQST_SIZE];
/* extract TXT from DNS response */
if (parse_dns_response(self, answer, ans_len, ans_id) == -1)
kill_dns_thread(dns_obj);
uint8_t encrypted_id[MAX_DNS_REQST_SIZE];
char encrypted_id[MAX_DNS_REQST_SIZE];
int prfx_len = strlen(TOX_DNS3_TXT_PREFIX);
/* extract the encrypted ID from TXT response */
@ -270,7 +272,8 @@ void *dns3_lookup_thread(void *data)
memcpy(encrypted_id, ans_id + prfx_len, ans_len - prfx_len);
if (tox_decrypt_dns3_TXT(dns_obj, t_data.id_bin, encrypted_id, strlen(encrypted_id), request_id) == -1) {
if (tox_decrypt_dns3_TXT(dns_obj, (uint8_t *) t_data.id_bin, (uint8_t *) encrypted_id, strlen(encrypted_id),
request_id) == -1) {
dns_error(self, "Core failed to decrypt DNS response.");
kill_dns_thread(dns_obj);
}
@ -284,10 +287,10 @@ void *dns3_lookup_thread(void *data)
}
/* creates new thread for dns3 lookup. Only allows one lookup at a time. */
void dns3_lookup(ToxWindow *self, Tox *m, uint8_t *id_bin, uint8_t *addr, uint8_t *msg)
void dns3_lookup(ToxWindow *self, Tox *m, char *id_bin, char *addr, char *msg)
{
if (t_data.busy) {
uint8_t *err = "Please wait for previous user lookup to finish.";
char *err = "Please wait for previous user lookup to finish.";
line_info_add(self, NULL, NULL, NULL, err, SYS_MSG, 0, 0);
return;
}

View File

@ -27,6 +27,6 @@
#define _dns_h
/* creates new thread for dns3 lookup. Only allows one lookup at a time. */
void dns3_lookup(ToxWindow *self, Tox *m, uint8_t *id_bin, uint8_t *addr, uint8_t *msg);
void dns3_lookup(ToxWindow *self, Tox *m, char *id_bin, char *addr, char *msg);
#endif /* #define _dns_h */

View File

@ -91,7 +91,7 @@ static int parse_command(WINDOW *w, ToxWindow *self, char *cmd, char (*args)[MAX
end = strchr(cmd + 1, '\"');
if (end++ == NULL) { /* Increment past the end quote */
uint8_t *errmsg = "Invalid argument. Did you forget a closing \"?";
char *errmsg = "Invalid argument. Did you forget a closing \"?";
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
return -1;
}
@ -134,7 +134,7 @@ void execute(WINDOW *w, ToxWindow *self, Tox *m, char *cmd, int mode)
if (string_is_empty(cmd))
return;
char args[MAX_NUM_ARGS][MAX_STR_SIZE] = {0};
char args[MAX_NUM_ARGS][MAX_STR_SIZE];
int num_args = parse_command(w, self, cmd, args);
if (num_args == -1)
@ -158,6 +158,5 @@ void execute(WINDOW *w, ToxWindow *self, Tox *m, char *cmd, int mode)
if (do_command(w, self, m, num_args, GLOBAL_NUM_COMMANDS, global_commands, args) == 0)
return;
uint8_t *errmsg = "Invalid command.";
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
line_info_add(self, NULL, NULL, NULL, "Invalid command.", SYS_MSG, 0, 0);
}

View File

@ -46,7 +46,7 @@ static void set_max_file_senders_index(void)
max_file_senders_index = j;
}
static void close_file_sender(ToxWindow *self, Tox *m, int i, uint8_t *msg, int CTRL, int filenum, int32_t friendnum)
static void close_file_sender(ToxWindow *self, Tox *m, int i, char *msg, int CTRL, int filenum, int32_t friendnum)
{
if (self->chatwin != NULL) {
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
@ -77,7 +77,7 @@ void close_all_file_senders(Tox *m)
void do_file_senders(Tox *m)
{
uint8_t msg[MAX_STR_SIZE];
char msg[MAX_STR_SIZE];
int i;
for (i = 0; i < max_file_senders_index; ++i) {
@ -85,7 +85,7 @@ void do_file_senders(Tox *m)
continue;
ToxWindow *self = file_senders[i].toxwin;
uint8_t *pathname = file_senders[i].pathname;
char *pathname = file_senders[i].pathname;
int filenum = file_senders[i].filenum;
int32_t friendnum = file_senders[i].friendnum;
FILE *fp = file_senders[i].file;
@ -98,7 +98,7 @@ void do_file_senders(Tox *m)
}
while (true) {
if (tox_file_send_data(m, friendnum, filenum, file_senders[i].nextpiece,
if (tox_file_send_data(m, friendnum, filenum, (uint8_t *) file_senders[i].nextpiece,
file_senders[i].piecelen) == -1)
break;

View File

@ -27,7 +27,7 @@
#include "windows.h"
#define FILE_PIECE_SIZE 2048 /* must be >= (MAX_CRYPTO_DATA_SIZE - 2) in toxcore/net_crypto.h */
#define MAX_FILES 256
#define MAX_FILES 255
#define TIMEOUT_FILESENDER 120
typedef struct {
@ -36,9 +36,9 @@ typedef struct {
int32_t friendnum;
bool active;
int filenum;
uint8_t nextpiece[FILE_PIECE_SIZE];
char nextpiece[FILE_PIECE_SIZE];
uint16_t piecelen;
uint8_t pathname[MAX_STR_SIZE];
char pathname[MAX_STR_SIZE];
uint64_t timestamp;
uint64_t last_progress;
uint64_t size;

View File

@ -96,7 +96,7 @@ static void update_friend_last_online(int32_t num, uint64_t timestamp)
&friends[num].last_online.tm);
}
static void friendlist_onMessage(ToxWindow *self, Tox *m, int32_t num, const uint8_t *str, uint16_t len)
static void friendlist_onMessage(ToxWindow *self, Tox *m, int32_t num, const char *str, uint16_t len)
{
if (num >= max_friends_index)
return;
@ -105,17 +105,17 @@ static void friendlist_onMessage(ToxWindow *self, Tox *m, int32_t num, const uin
if (get_num_active_windows() < MAX_WINDOWS_NUM) {
friends[num].chatwin = add_window(m, new_chat(m, friends[num].num));
} else {
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
int n_len = tox_get_name(m, num, nick);
char nick[TOX_MAX_NAME_LENGTH];
int n_len = tox_get_name(m, num, (uint8_t *) nick);
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH - 1);
nick[n_len] = '\0';
uint8_t timefrmt[TIME_STR_SIZE];
char timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt, sizeof(timefrmt));
line_info_add(prompt, timefrmt, nick, NULL, str, IN_MSG, 0, 0);
uint8_t *msg = "* Warning: Too many windows are open.";
char *msg = "* Warning: Too many windows are open.";
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, RED);
alert_window(prompt, WINDOW_ALERT_1, true);
}
@ -133,7 +133,7 @@ static void friendlist_onConnectionChange(ToxWindow *self, Tox *m, int32_t num,
sort_friendlist_index();
}
static void friendlist_onNickChange(ToxWindow *self, Tox *m, int32_t num, const uint8_t *nick, uint16_t len)
static void friendlist_onNickChange(ToxWindow *self, Tox *m, int32_t num, const char *nick, uint16_t len)
{
if (len > TOX_MAX_NAME_LENGTH || num >= max_friends_index)
return;
@ -151,7 +151,7 @@ static void friendlist_onStatusChange(ToxWindow *self, Tox *m, int32_t num, uint
friends[num].status = status;
}
static void friendlist_onStatusMessageChange(ToxWindow *self, int32_t num, const uint8_t *status, uint16_t len)
static void friendlist_onStatusMessageChange(ToxWindow *self, int32_t num, const char *status, uint16_t len)
{
if (len > TOX_MAX_STATUSMESSAGE_LENGTH || num >= max_friends_index)
return;
@ -174,13 +174,13 @@ void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int32_t num, bool sort)
friends[i].chatwin = -1;
friends[i].online = false;
friends[i].status = TOX_USERSTATUS_NONE;
friends[i].namelength = tox_get_name(m, num, friends[i].name);
friends[i].namelength = tox_get_name(m, num, (uint8_t *) friends[i].name);
friends[i].logging_on = (bool) user_settings->autolog == AUTOLOG_ON;
tox_get_client_id(m, num, friends[i].pub_key);
tox_get_client_id(m, num, (uint8_t *) friends[i].pub_key);
update_friend_last_online(i, tox_get_last_online(m, i));
if (friends[i].namelength == -1 || friends[i].name[0] == '\0') {
strcpy(friends[i].name, (uint8_t *) UNKNOWN_NAME);
strcpy(friends[i].name, UNKNOWN_NAME);
friends[i].namelength = strlen(UNKNOWN_NAME);
} else { /* Enforce toxic's maximum name length */
friends[i].namelength = MIN(friends[i].namelength, TOXIC_MAX_NAME_LENGTH);
@ -201,7 +201,7 @@ void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int32_t num, bool sort)
}
static void friendlist_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, uint8_t filenum,
uint64_t filesize, const uint8_t *filename, uint16_t filename_len)
uint64_t filesize, const char *filename, uint16_t filename_len)
{
if (num >= max_friends_index)
return;
@ -212,12 +212,12 @@ static void friendlist_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, u
} else {
tox_file_send_control(m, num, 1, filenum, TOX_FILECONTROL_KILL, 0, 0);
uint8_t nick[TOX_MAX_NAME_LENGTH];
int n_len = tox_get_name(m, num, nick);
char nick[TOX_MAX_NAME_LENGTH];
int n_len = tox_get_name(m, num, (uint8_t *) nick);
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH - 1);
nick[n_len] = '\0';
uint8_t msg[MAX_STR_SIZE];
char msg[MAX_STR_SIZE];
snprintf(msg, sizeof(msg), "* File transfer from %s failed: too many windows are open.", nick);
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, RED);
@ -226,7 +226,7 @@ static void friendlist_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, u
}
}
static void friendlist_onGroupInvite(ToxWindow *self, Tox *m, int32_t num, const uint8_t *group_pub_key)
static void friendlist_onGroupInvite(ToxWindow *self, Tox *m, int32_t num, const char *group_pub_key)
{
if (num >= max_friends_index)
return;
@ -235,12 +235,12 @@ static void friendlist_onGroupInvite(ToxWindow *self, Tox *m, int32_t num, const
if (get_num_active_windows() < MAX_WINDOWS_NUM) {
friends[num].chatwin = add_window(m, new_chat(m, friends[num].num));
} else {
uint8_t nick[TOX_MAX_NAME_LENGTH];
int n_len = tox_get_name(m, num, nick);
char nick[TOX_MAX_NAME_LENGTH];
int n_len = tox_get_name(m, num, (uint8_t *) nick);
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH - 1);
nick[n_len] = '\0';
uint8_t msg[MAX_STR_SIZE];
char msg[MAX_STR_SIZE];
snprintf(msg, sizeof(msg), "* Group chat invite from %s failed: too many windows are open.", nick);
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, RED);
@ -345,7 +345,7 @@ static void friendlist_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
friends[f].chatwin = add_window(m, new_chat(m, friends[f].num));
set_active_window(friends[f].chatwin);
} else {
uint8_t *msg = "* Warning: Too many windows are open.";
char *msg = "* Warning: Too many windows are open.";
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, RED);
alert_window(prompt, WINDOW_ALERT_1, true);
@ -458,10 +458,10 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
/* Reset friends[f].statusmsg on window resize */
if (fix_statuses) {
uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH] = {'\0'};
char statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH];
pthread_mutex_lock(&Winthread.lock);
tox_get_status_message(m, friends[f].num, statusmsg, TOX_MAX_STATUSMESSAGE_LENGTH);
tox_get_status_message(m, friends[f].num, (uint8_t *) statusmsg, TOX_MAX_STATUSMESSAGE_LENGTH);
pthread_mutex_unlock(&Winthread.lock);
snprintf(friends[f].statusmsg, sizeof(friends[f].statusmsg), "%s", statusmsg);
@ -499,7 +499,7 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
if (last_seen != 0) {
int day_dist = (cur_loc_tm.tm_yday - friends[f].last_online.tm.tm_yday) % 365;
const uint8_t *hourmin = friends[f].last_online.hour_min_str;
const char *hourmin = friends[f].last_online.hour_min_str;
switch (day_dist) {
case 0:
@ -561,17 +561,17 @@ static void friendlist_onAv(ToxWindow *self, ToxAv *av, int call_index)
if (toxav_get_call_state(av, call_index) == av_CallStarting) /* Only open windows when call is incoming */
friends[id].chatwin = add_window(m, new_chat(m, friends[id].num));
} else {
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
int n_len = tox_get_name(m, id, nick);
char nick[TOX_MAX_NAME_LENGTH];
int n_len = tox_get_name(m, id, (uint8_t *) nick);
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH - 1);
nick[n_len] = '\0';
uint8_t msg[MAX_STR_SIZE];
char msg[MAX_STR_SIZE];
snprintf(msg, sizeof(msg), "Audio action from: %s!", nick);
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
uint8_t *errmsg = "* Warning: Too many windows are open.";
char *errmsg = "* Warning: Too many windows are open.";
line_info_add(prompt, NULL, NULL, NULL, errmsg, SYS_MSG, 0, RED);
alert_window(prompt, WINDOW_ALERT_0, true);

View File

@ -30,7 +30,7 @@
#include "file_senders.h"
struct FileReceiver {
uint8_t filenames[MAX_FILES][MAX_STR_SIZE];
char filenames[MAX_FILES][MAX_STR_SIZE];
FILE *files[MAX_FILES];
bool pending[MAX_FILES];
uint64_t size[MAX_FILES];
@ -41,17 +41,17 @@ struct FileReceiver {
struct LastOnline {
uint64_t last_on;
struct tm tm;
uint8_t hour_min_str[TIME_STR_SIZE]; /* holds 12/24-hour time string e.g. "10:43 PM" */
char hour_min_str[TIME_STR_SIZE]; /* holds 12/24-hour time string e.g. "10:43 PM" */
};
typedef struct {
uint8_t name[TOX_MAX_NAME_LENGTH];
char name[TOX_MAX_NAME_LENGTH];
uint16_t namelength;
uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH];
char statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH];
uint16_t statusmsg_len;
uint8_t groupchat_key[TOX_CLIENT_ID_SIZE];
char groupchat_key[TOX_CLIENT_ID_SIZE];
bool groupchat_pending;
uint8_t pub_key[TOX_CLIENT_ID_SIZE];
char pub_key[TOX_CLIENT_ID_SIZE];
int32_t num;
int chatwin;
bool active;

View File

@ -40,13 +40,13 @@ extern ToxWindow *prompt;
extern ToxicFriend friends[MAX_FRIENDS_NUM];
extern uint8_t pending_frnd_requests[MAX_FRIENDS_NUM][TOX_CLIENT_ID_SIZE];
extern char pending_frnd_requests[MAX_FRIENDS_NUM][TOX_CLIENT_ID_SIZE];
extern uint8_t num_frnd_requests;
/* command functions */
void cmd_accept(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *msg;
char *msg;
if (argc != 1) {
msg = "Invalid syntax.";
@ -68,7 +68,7 @@ void cmd_accept(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
return;
}
int32_t friendnum = tox_add_friend_norequest(m, pending_frnd_requests[req]);
int32_t friendnum = tox_add_friend_norequest(m, (uint8_t *) pending_frnd_requests[req]);
if (friendnum == -1)
msg = "Failed to add friend.";
@ -90,10 +90,10 @@ void cmd_accept(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
}
void cmd_add_helper(ToxWindow *self, Tox *m, uint8_t *id_bin, uint8_t *msg)
void cmd_add_helper(ToxWindow *self, Tox *m, char *id_bin, char *msg)
{
uint8_t *errmsg;
int32_t f_num = tox_add_friend(m, id_bin, msg, strlen(msg));
char *errmsg;
int32_t f_num = tox_add_friend(m, (uint8_t *) id_bin, (uint8_t *) msg, (uint16_t) strlen(msg));
switch (f_num) {
case TOX_FAERR_TOOLONG:
@ -135,7 +135,7 @@ void cmd_add_helper(ToxWindow *self, Tox *m, uint8_t *id_bin, uint8_t *msg)
void cmd_add(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *errmsg;
char *errmsg;
if (argc < 1) {
errmsg = "Invalid syntax.";
@ -144,10 +144,10 @@ void cmd_add(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
}
char *id = argv[1];
uint8_t msg[MAX_STR_SIZE];
char msg[MAX_STR_SIZE];
if (argc > 1) {
uint8_t *temp = argv[2];
char *temp = argv[2];
if (temp[0] != '\"') {
errmsg = "Message must be enclosed in quotes.";
@ -155,17 +155,18 @@ void cmd_add(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
return;
}
temp[strlen(++temp) - 1] = L'\0';
++temp;
temp[strlen(temp) - 1] = L'\0';
snprintf(msg, sizeof(msg), "%s", temp);
} else {
uint8_t selfname[TOX_MAX_NAME_LENGTH];
uint16_t n_len = tox_get_self_name(m, selfname);
char selfname[TOX_MAX_NAME_LENGTH];
uint16_t n_len = tox_get_self_name(m, (uint8_t *) selfname);
selfname[n_len] = '\0';
snprintf(msg, sizeof(msg), "Hello, my name is %s. Care to Tox?", selfname);
}
uint8_t id_bin[TOX_FRIEND_ADDRESS_SIZE] = {0};
uint16_t id_len = strlen(id);
char id_bin[TOX_FRIEND_ADDRESS_SIZE] = {0};
uint16_t id_len = (uint16_t) strlen(id);
/* try to add tox ID */
if (id_len == 2 * TOX_FRIEND_ADDRESS_SIZE) {
@ -203,7 +204,7 @@ void cmd_clear(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[M
void cmd_connect(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *errmsg;
char *errmsg;
/* check arguments */
if (argc != 3) {
@ -212,9 +213,9 @@ void cmd_connect(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)
return;
}
char *ip = argv[1];
char *port = argv[2];
char *key = argv[3];
const char *ip = argv[1];
const char *port = argv[2];
const char *key = argv[3];
if (atoi(port) == 0) {
errmsg = "Invalid syntax.";
@ -222,15 +223,14 @@ void cmd_connect(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)
return;
}
uint8_t *binary_string = hex_string_to_bin(key);
tox_bootstrap_from_address(m, ip, TOX_ENABLE_IPV6_DEFAULT,
htons(atoi(port)), binary_string);
char *binary_string = hex_string_to_bin(key);
tox_bootstrap_from_address(m, ip, TOX_ENABLE_IPV6_DEFAULT, htons(atoi(port)), (uint8_t *) binary_string);
free(binary_string);
}
void cmd_groupchat(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *errmsg;
char *errmsg;
if (get_num_active_windows() >= MAX_WINDOWS_NUM) {
errmsg = " * Warning: Too many windows are open.";
@ -253,14 +253,14 @@ void cmd_groupchat(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
return;
}
uint8_t msg[MAX_STR_SIZE];
char msg[MAX_STR_SIZE];
snprintf(msg, sizeof(msg), "Group chat created as %d.", groupnum);
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
}
void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *msg;
char *msg;
struct chatlog *log = self->chatwin->log;
if (argc == 0) {
@ -273,7 +273,7 @@ void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
return;
}
uint8_t *swch = argv[1];
char *swch = argv[1];
if (!strcmp(swch, "1") || !strcmp(swch, "on")) {
@ -281,8 +281,8 @@ void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
friends[self->num].logging_on = true;
log_enable(self->name, friends[self->num].pub_key, log);
} else if (self->is_prompt) {
uint8_t myid[TOX_FRIEND_ADDRESS_SIZE];
tox_get_address(m, myid);
char myid[TOX_FRIEND_ADDRESS_SIZE];
tox_get_address(m, (uint8_t *) myid);
log_enable(self->name, myid, log);
} else if (self->is_groupchat) {
log_enable(self->name, NULL, log);
@ -309,8 +309,8 @@ void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
void cmd_myid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
char id[TOX_FRIEND_ADDRESS_SIZE * 2 + 1] = {0};
uint8_t address[TOX_FRIEND_ADDRESS_SIZE];
tox_get_address(m, address);
char address[TOX_FRIEND_ADDRESS_SIZE];
tox_get_address(m, (uint8_t *) address);
size_t i;
@ -325,7 +325,7 @@ void cmd_myid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *errmsg;
char *errmsg;
/* check arguments */
if (argc < 1) {
@ -334,13 +334,13 @@ void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
return;
}
uint8_t *nick = argv[1];
char *nick = argv[1];
int len = strlen(nick);
if (nick[0] == '\"') {
++nick;
len -= 2;
nick[len] = L'\0';
nick[len] = '\0';
}
if (!valid_nick(nick)) {
@ -350,18 +350,17 @@ void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
}
len = MIN(len, TOXIC_MAX_NAME_LENGTH - 1);
nick[len] = '\0';
nick[len] = L'\0';
tox_set_name(m, nick, len);
prompt_update_nick(prompt, nick, len);
tox_set_name(m, (uint8_t *) nick, (uint16_t) len);
prompt_update_nick(prompt, nick);
store_data(m, DATA_FILE);
}
void cmd_note(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *errmsg;
char *errmsg;
if (argc < 1) {
errmsg = "Wrong number of arguments.";
@ -369,7 +368,7 @@ void cmd_note(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
return;
}
uint8_t *msg = argv[1];
char *msg = argv[1];
if (msg[0] != '\"') {
errmsg = "Note must be enclosed in quotes.";
@ -377,10 +376,11 @@ void cmd_note(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
return;
}
msg[strlen(++msg) - 1] = L'\0';
uint16_t len = strlen(msg);
tox_set_status_message(m, msg, len);
prompt_update_statusmessage(prompt, msg, len);
++msg;
msg[strlen(msg) - 1] = '\0';
int len = strlen(msg);
tox_set_status_message(m, (uint8_t *) msg, (uint16_t) len);
prompt_update_statusmessage(prompt, msg);
}
void cmd_prompt_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
@ -395,8 +395,8 @@ void cmd_quit(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
void cmd_status(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
uint8_t *msg = NULL;
uint8_t *errmsg;
char *msg = NULL;
char *errmsg;
if (argc >= 2) {
msg = argv[2];
@ -414,7 +414,6 @@ void cmd_status(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
char *status = argv[1];
str_to_lower(status);
int len = strlen(status);
TOX_USERSTATUS status_kind;
@ -434,9 +433,10 @@ void cmd_status(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
prompt_update_status(prompt, status_kind);
if (msg != NULL) {
msg[strlen(++msg) - 1] = L'\0'; /* remove opening and closing quotes */
uint16_t len = strlen(msg);
tox_set_status_message(m, msg, len);
prompt_update_statusmessage(prompt, msg, len);
++msg;
msg[strlen(msg) - 1] = L'\0'; /* remove opening and closing quotes */
int len = strlen(msg);
tox_set_status_message(m, (uint8_t *) msg, (uint16_t) len);
prompt_update_statusmessage(prompt, msg);
}
}

View File

@ -39,7 +39,7 @@ void cmd_prompt_help(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_ST
void cmd_quit(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_status(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_add_helper(ToxWindow *self, Tox *m, uint8_t *id_bin, uint8_t *msg);
void cmd_add_helper(ToxWindow *self, Tox *m, char *id_bin, char *msg);
#ifdef _SUPPORT_AUDIO
void cmd_list_devices(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);

View File

@ -50,7 +50,7 @@ static int max_groupchat_index = 0;
extern struct user_settings *user_settings;
/* temporary until group chats have unique commands */
extern const uint8_t glob_cmd_list[AC_NUM_GLOB_COMMANDS][MAX_CMDNAME_SIZE];
extern const char glob_cmd_list[AC_NUM_GLOB_COMMANDS][MAX_CMDNAME_SIZE];
int init_groupchat_win(ToxWindow *prompt, Tox *m, int groupnum)
{
@ -124,15 +124,15 @@ static void close_groupchat(ToxWindow *self, Tox *m, int groupnum)
}
static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int peernum,
const uint8_t *msg, uint16_t len)
const char *msg, uint16_t len)
{
if (self->num != groupnum)
return;
ChatContext *ctx = self->chatwin;
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
int n_len = tox_group_peername(m, groupnum, peernum, nick);
char nick[TOX_MAX_NAME_LENGTH];
int n_len = tox_group_peername(m, groupnum, peernum, (uint8_t *) nick);
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH - 1); /* enforce client max name length */
nick[n_len] = '\0';
@ -141,8 +141,8 @@ static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int
int alert_type = WINDOW_ALERT_1;
bool beep = false;
uint8_t selfnick[TOX_MAX_NAME_LENGTH];
uint16_t sn_len = tox_get_self_name(m, selfnick);
char selfnick[TOX_MAX_NAME_LENGTH];
uint16_t sn_len = tox_get_self_name(m, (uint8_t *) selfnick);
selfnick[sn_len] = '\0';
int nick_clr = strcmp(nick, selfnick) == 0 ? GREEN : CYAN;
@ -157,14 +157,14 @@ static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int
alert_window(self, alert_type, beep);
uint8_t timefrmt[TIME_STR_SIZE];
char timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt, sizeof(timefrmt));
line_info_add(self, timefrmt, nick, NULL, msg, IN_MSG, 0, nick_clr);
write_to_log(msg, nick, ctx->log, false);
}
static void groupchat_onGroupAction(ToxWindow *self, Tox *m, int groupnum, int peernum, const uint8_t *action,
static void groupchat_onGroupAction(ToxWindow *self, Tox *m, int groupnum, int peernum, const char *action,
uint16_t len)
{
if (self->num != groupnum)
@ -176,8 +176,8 @@ static void groupchat_onGroupAction(ToxWindow *self, Tox *m, int groupnum, int p
int alert_type = WINDOW_ALERT_1;
bool beep = false;
uint8_t selfnick[TOX_MAX_NAME_LENGTH];
uint16_t n_len = tox_get_self_name(m, selfnick);
char selfnick[TOX_MAX_NAME_LENGTH];
uint16_t n_len = tox_get_self_name(m, (uint8_t *) selfnick);
selfnick[n_len] = '\0';
bool nick_match = strcasestr(action, selfnick);
@ -189,13 +189,12 @@ static void groupchat_onGroupAction(ToxWindow *self, Tox *m, int groupnum, int p
alert_window(self, alert_type, beep);
uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
n_len = tox_group_peername(m, groupnum, peernum, nick);
char nick[TOX_MAX_NAME_LENGTH];
n_len = tox_group_peername(m, groupnum, peernum, (uint8_t *) nick);
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH - 1);
nick[n_len] = '\0';
uint8_t timefrmt[TIME_STR_SIZE];
char timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt, sizeof(timefrmt));
line_info_add(self, timefrmt, nick, NULL, action, ACTION, 0, 0);
@ -223,11 +222,11 @@ static void copy_peernames(int gnum, uint8_t peerlist[][TOX_MAX_NAME_LENGTH], ui
exit_toxic_err("failed in copy_peernames", FATALERR_MEMORY);
}
uint16_t unknown_len = strlen(UNKNOWN_NAME);
uint16_t unknown_len = (uint16_t) strlen(UNKNOWN_NAME);
int i;
for (i = 0; i < npeers; ++i) {
if (string_is_empty(peerlist[i])) {
if (string_is_empty((char *) peerlist[i])) {
memcpy(&groupchats[gnum].peer_names[i * N], UNKNOWN_NAME, sizeof(UNKNOWN_NAME));
groupchats[gnum].peer_name_lengths[i] = unknown_len;
} else {
@ -247,7 +246,7 @@ static void copy_peernames(int gnum, uint8_t peerlist[][TOX_MAX_NAME_LENGTH], ui
}
static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnum, int peernum,
uint8_t change)
uint8_t change)
{
if (self->num != groupnum)
return;
@ -290,49 +289,49 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu
ChatContext *ctx = self->chatwin;
uint8_t *event;
uint8_t timefrmt[TIME_STR_SIZE];
char *event;
char timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt, sizeof(timefrmt));
switch (change) {
case TOX_CHAT_CHANGE_PEER_ADD:
event = "has joined the room";
line_info_add(self, timefrmt, peername, NULL, event, CONNECTION, 0, GREEN);
write_to_log(event, peername, ctx->log, true);
line_info_add(self, timefrmt, (char *) peername, NULL, event, CONNECTION, 0, GREEN);
write_to_log(event, (char *) peername, ctx->log, true);
break;
case TOX_CHAT_CHANGE_PEER_DEL:
event = "has left the room";
line_info_add(self, timefrmt, oldpeername, NULL, event, CONNECTION, 0, 0);
line_info_add(self, timefrmt, (char *) oldpeername, NULL, event, CONNECTION, 0, 0);
if (groupchats[self->num].side_pos > 0)
--groupchats[self->num].side_pos;
write_to_log(event, oldpeername, ctx->log, true);
write_to_log(event, (char *) oldpeername, ctx->log, true);
break;
case TOX_CHAT_CHANGE_PEER_NAME:
event = " is now known as ";
line_info_add(self, timefrmt, oldpeername, peername, event, NAME_CHANGE, 0, 0);
line_info_add(self, timefrmt, (char *) oldpeername, (char *) peername, event, NAME_CHANGE, 0, 0);
uint8_t tmp_event[TOXIC_MAX_NAME_LENGTH * 2 + 32];
snprintf(tmp_event, sizeof(tmp_event), "is now known as %s", peername);
write_to_log(tmp_event, oldpeername, ctx->log, true);
char tmp_event[TOXIC_MAX_NAME_LENGTH * 2 + 32];
snprintf(tmp_event, sizeof(tmp_event), "is now known as %s", (char *) peername);
write_to_log(tmp_event, (char *) oldpeername, ctx->log, true);
break;
}
alert_window(self, WINDOW_ALERT_2, false);
}
static void send_group_action(ToxWindow *self, ChatContext *ctx, Tox *m, uint8_t *action)
static void send_group_action(ToxWindow *self, ChatContext *ctx, Tox *m, char *action)
{
if (action == NULL) {
wprintw(ctx->history, "Invalid syntax.\n");
return;
}
if (tox_group_action_send(m, self->num, action, strlen(action)) == -1) {
uint8_t *errmsg = " * Failed to send action.";
if (tox_group_action_send(m, self->num, (uint8_t *) action, strlen(action)) == -1) {
char *errmsg = " * Failed to send action.";
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, RED);
}
}
@ -398,7 +397,7 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
} else if (key == '\n') {
rm_trailing_spaces_buf(ctx);
uint8_t line[MAX_STR_SIZE];
char line[MAX_STR_SIZE];
if (wcs_to_mbs_buf(line, ctx->line, MAX_STR_SIZE) == -1)
memset(&line, 0, sizeof(line));
@ -416,8 +415,8 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
execute(ctx->history, self, m, line, GROUPCHAT_COMMAND_MODE);
}
} else if (!string_is_empty(line)) {
if (tox_group_message_send(m, self->num, line, strlen(line)) == -1) {
uint8_t *errmsg = " * Failed to send message.";
if (tox_group_message_send(m, self->num, (uint8_t *) line, strlen(line)) == -1) {
char *errmsg = " * Failed to send message.";
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, RED);
}
}
@ -468,7 +467,7 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
int peer = i + groupchats[self->num].side_pos;
/* truncate nick to fit in side panel without modifying list */
uint8_t tmpnck[TOX_MAX_NAME_LENGTH];
char tmpnck[TOX_MAX_NAME_LENGTH];
memcpy(tmpnck, &groupchats[self->num].peer_names[peer * N], SIDEBAR_WIDTH - 2);
tmpnck[SIDEBAR_WIDTH - 2] = '\0';
@ -477,6 +476,7 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
int y, x;
getyx(self->window, y, x);
(void) x;
int new_x = ctx->start ? x2 - 1 : ctx->pos;
wmove(self->window, y + 1, new_x);

View File

@ -105,6 +105,8 @@ static void help_draw_bottom_menu(WINDOW *win)
{
int y2, x2;
getmaxyx(win, y2, x2);
(void) x2;
wmove(win, y2 - 2, 1);
wattron(win, A_BOLD | COLOR_PAIR(BLUE));

View File

@ -126,8 +126,8 @@ static struct line_info *line_info_ret_queue(struct history *hst)
}
/* creates new line_info line and puts it in the queue */
void line_info_add(ToxWindow *self, uint8_t *tmstmp, uint8_t *name1, uint8_t *name2, const uint8_t *msg,
uint8_t type, uint8_t bold, uint8_t colour)
void line_info_add(ToxWindow *self, char *tmstmp, char *name1, char *name2, const char *msg, uint8_t type,
uint8_t bold, uint8_t colour)
{
struct history *hst = self->chatwin->hst;
struct line_info *new_line = calloc(1, sizeof(struct line_info));
@ -211,6 +211,7 @@ static void line_info_check_queue(ToxWindow *self)
int y, y2, x, x2;
getmaxyx(self->window, y2, x2);
getyx(self->chatwin->history, y, x);
(void) x;
if (x2 <= SIDEBAR_WIDTH)
return;
@ -255,7 +256,6 @@ void line_info_print(ToxWindow *self)
wmove(win, 2, 0);
struct line_info *line = hst->line_start->next;
int offst = self->is_groupchat ? SIDEBAR_WIDTH : 0;
int numlines = 0;
while (line && numlines++ <= y2) {
@ -376,7 +376,7 @@ void line_info_print(ToxWindow *self)
line_info_print(self);
}
void line_info_set(ToxWindow *self, uint32_t id, uint8_t *msg)
void line_info_set(ToxWindow *self, uint32_t id, char *msg)
{
struct line_info *line = self->chatwin->hst->line_end;
@ -390,10 +390,10 @@ void line_info_set(ToxWindow *self, uint32_t id, uint8_t *msg)
}
}
static void line_info_goto_root(struct history *hst)
/* static void line_info_goto_root(struct history *hst)
{
hst->line_start = hst->line_root;
}
} */
static void line_info_scroll_up(struct history *hst)
{
@ -413,6 +413,7 @@ static void line_info_page_up(ToxWindow *self, struct history *hst)
{
int x2, y2;
getmaxyx(self->window, y2, x2);
(void) x2;
int jump_dist = y2 / 2;
int i;
@ -424,6 +425,7 @@ static void line_info_page_down(ToxWindow *self, struct history *hst)
{
int x2, y2;
getmaxyx(self->window, y2, x2);
(void) x2;
int jump_dist = y2 / 2;
int i;

View File

@ -41,10 +41,10 @@ enum {
} LINE_TYPE;
struct line_info {
uint8_t timestamp[TIME_STR_SIZE];
uint8_t name1[TOXIC_MAX_NAME_LENGTH];
uint8_t name2[TOXIC_MAX_NAME_LENGTH];
uint8_t msg[TOX_MAX_MESSAGE_LENGTH];
char timestamp[TIME_STR_SIZE];
char name1[TOXIC_MAX_NAME_LENGTH];
char name2[TOXIC_MAX_NAME_LENGTH];
char msg[TOX_MAX_MESSAGE_LENGTH];
uint8_t type;
uint8_t bold;
uint8_t colour;
@ -68,7 +68,7 @@ struct history {
};
/* creates new line_info line and puts it in the queue */
void line_info_add(ToxWindow *self, uint8_t *tmstmp, uint8_t *name1, uint8_t *name2, const uint8_t *msg,
void line_info_add(ToxWindow *self, char *tmstmp, char *name1, char *name2, const char *msg,
uint8_t type, uint8_t bold, uint8_t colour);
/* Prints a section of history starting at line_start */
@ -81,7 +81,7 @@ void line_info_cleanup(struct history *hst);
void line_info_clear(struct history *hst);
/* puts msg in specified line_info msg buffer */
void line_info_set(ToxWindow *self, uint32_t id, uint8_t *msg);
void line_info_set(ToxWindow *self, uint32_t id, char *msg);
void line_info_init(struct history *hst);
bool line_info_onKey(ToxWindow *self, wint_t key); /* returns true if key is a match */

View File

@ -34,7 +34,7 @@
extern struct user_settings *user_settings;
/* Creates/fetches log file by appending to the config dir the name and a pseudo-unique identity */
void init_logging_session(uint8_t *name, uint8_t *key, struct chatlog *log)
void init_logging_session(char *name, char *key, struct chatlog *log)
{
if (!log->log_on)
return;
@ -46,7 +46,7 @@ void init_logging_session(uint8_t *name, uint8_t *key, struct chatlog *log)
int path_len = strlen(user_config_dir) + strlen(CONFIGDIR) + strlen(name);
/* use first 4 digits of key as log ident. If no key use a timestamp */
uint8_t ident[32];
char ident[32];
if (key != NULL) {
path_len += (KEY_IDENT_DIGITS * 2 + 5);
@ -65,7 +65,7 @@ void init_logging_session(uint8_t *name, uint8_t *key, struct chatlog *log)
return;
}
uint8_t log_path[MAX_STR_SIZE];
char log_path[MAX_STR_SIZE];
snprintf(log_path, MAX_STR_SIZE, "%s%s%s-%s.log",
user_config_dir, CONFIGDIR, name, ident);
@ -82,7 +82,7 @@ void init_logging_session(uint8_t *name, uint8_t *key, struct chatlog *log)
fprintf(log->file, "\n*** NEW SESSION ***\n\n");
}
void write_to_log(const uint8_t *msg, uint8_t *name, struct chatlog *log, bool event)
void write_to_log(const char *msg, char *name, struct chatlog *log, bool event)
{
if (!log->log_on)
return;
@ -92,7 +92,7 @@ void write_to_log(const uint8_t *msg, uint8_t *name, struct chatlog *log, bool e
return;
}
uint8_t name_frmt[TOXIC_MAX_NAME_LENGTH + 3];
char name_frmt[TOXIC_MAX_NAME_LENGTH + 3];
if (event)
snprintf(name_frmt, sizeof(name_frmt), "* %s", name);
@ -100,7 +100,7 @@ void write_to_log(const uint8_t *msg, uint8_t *name, struct chatlog *log, bool e
snprintf(name_frmt, sizeof(name_frmt), "%s:", name);
const char *t = user_settings->time == TIME_12 ? "%Y/%m/%d [%I:%M:%S %p]" : "%Y/%m/%d [%H:%M:%S]";
uint8_t s[MAX_STR_SIZE];
char s[MAX_STR_SIZE];
strftime(s, MAX_STR_SIZE, t, get_time());
fprintf(log->file, "%s %s %s\n", s, name_frmt, msg);
@ -112,7 +112,7 @@ void write_to_log(const uint8_t *msg, uint8_t *name, struct chatlog *log, bool e
}
}
void log_enable(uint8_t *name, uint8_t *key, struct chatlog *log)
void log_enable(char *name, char *key, struct chatlog *log)
{
log->log_on = true;

View File

@ -33,13 +33,13 @@ struct chatlog {
};
/* Creates/fetches log file by appending to the config dir the name and a pseudo-unique identity */
void init_logging_session(uint8_t *name, uint8_t *key, struct chatlog *log);
void init_logging_session(char *name, char *key, struct chatlog *log);
/* formats/writes line to log file */
void write_to_log(const uint8_t *msg, uint8_t *name, struct chatlog *log, bool event);
void write_to_log(const char *msg, char *name, struct chatlog *log, bool event);
/* enables logging for specified log and creates/fetches file if necessary */
void log_enable(uint8_t *name, uint8_t *key, struct chatlog *log);
void log_enable(char *name, char *key, struct chatlog *log);
/* disables logging for specified log and closes file */
void log_disable(struct chatlog *log);

View File

@ -51,12 +51,12 @@ struct tm *get_time(void)
{
struct tm *timeinfo;
uint64_t t = get_unix_time();
timeinfo = localtime((const time_t*)&t);
timeinfo = localtime((const time_t*) &t);
return timeinfo;
}
/*Puts the current time in buf in the format of [HH:mm:ss] */
void get_time_str(uint8_t *buf, int bufsize)
void get_time_str(char *buf, int bufsize)
{
if (user_settings->timestamps == TIMESTAMPS_OFF) {
buf[0] = '\0';
@ -68,7 +68,7 @@ void get_time_str(uint8_t *buf, int bufsize)
}
/* Converts seconds to string in format HH:mm:ss; truncates hours and minutes when necessary */
void get_elapsed_time_str(uint8_t *buf, int bufsize, uint64_t secs)
void get_elapsed_time_str(char *buf, int bufsize, uint64_t secs)
{
if (!secs)
return;
@ -108,7 +108,7 @@ int string_is_empty(char *string)
}
/* convert a multibyte string to a wide character string and puts in buf. */
int mbs_to_wcs_buf(wchar_t *buf, const uint8_t *string, size_t n)
int mbs_to_wcs_buf(wchar_t *buf, const char *string, size_t n)
{
size_t len = mbstowcs(NULL, string, 0) + 1;
@ -122,7 +122,7 @@ int mbs_to_wcs_buf(wchar_t *buf, const uint8_t *string, size_t n)
}
/* converts wide character string into a multibyte string and puts in buf. */
int wcs_to_mbs_buf(uint8_t *buf, const wchar_t *string, size_t n)
int wcs_to_mbs_buf(char *buf, const wchar_t *string, size_t n)
{
size_t len = wcstombs(NULL, string, 0) + 1;
@ -175,7 +175,7 @@ int qsort_strcasecmp_hlpr(const void *nick1, const void *nick2)
- cannot start with a space
- must not contain a forward slash (for logfile naming purposes)
- must not contain contiguous spaces */
int valid_nick(uint8_t *nick)
int valid_nick(char *nick)
{
if (!nick[0] || nick[0] == ' ')
return 0;
@ -194,17 +194,17 @@ int valid_nick(uint8_t *nick)
}
/* gets base file name from path or original file name if no path is supplied */
void get_file_name(uint8_t *namebuf, const uint8_t *pathname)
void get_file_name(char *namebuf, const char *pathname)
{
int idx = strlen(pathname) - 1;
uint8_t tmpname[MAX_STR_SIZE];
char tmpname[MAX_STR_SIZE];
snprintf(tmpname, sizeof(tmpname), "%s", pathname);
while (idx >= 0 && pathname[idx] == '/')
tmpname[idx--] = '\0';
uint8_t *filename = strrchr(tmpname, '/');
char *filename = strrchr(tmpname, '/');
if (filename != NULL) {
if (!strlen(++filename))
@ -217,7 +217,7 @@ void get_file_name(uint8_t *namebuf, const uint8_t *pathname)
}
/* converts str to all lowercase */
void str_to_lower(uint8_t *str)
void str_to_lower(char *str)
{
int i;

View File

@ -40,10 +40,10 @@ char *hex_string_to_bin(const char *hex_string);
uint64_t get_unix_time(void);
/*Puts the current time in buf in the format of [HH:mm:ss] */
void get_time_str(uint8_t *buf, int bufsize);
void get_time_str(char *buf, int bufsize);
/* Converts seconds to string in format HH:mm:ss; truncates hours and minutes when necessary */
void get_elapsed_time_str(uint8_t *buf, int bufsize, uint64_t secs);
void get_elapsed_time_str(char *buf, int bufsize, uint64_t secs);
/* get the current local time */
struct tm *get_time(void);
@ -55,13 +55,13 @@ void update_unix_time(void);
int string_is_empty(char *string);
/* convert a multibyte string to a wide character string (must provide buffer) */
int char_to_wcs_buf(wchar_t *buf, const uint8_t *string, size_t n);
int char_to_wcs_buf(wchar_t *buf, const char *string, size_t n);
/* converts wide character string into a multibyte string and puts in buf. */
int wcs_to_mbs_buf(uint8_t *buf, const wchar_t *string, size_t n);
int wcs_to_mbs_buf(char *buf, const wchar_t *string, size_t n);
/* convert a multibyte string to a wide character string and puts in buf) */
int mbs_to_wcs_buf(wchar_t *buf, const uint8_t *string, size_t n);
int mbs_to_wcs_buf(wchar_t *buf, const char *string, size_t n);
/* Returns 1 if connection has timed out, 0 otherwise */
int timed_out(uint64_t timestamp, uint64_t timeout, uint64_t curtime);
@ -77,12 +77,12 @@ int qsort_strcasecmp_hlpr(const void *nick1, const void *nick2);
- cannot start with a space
- must not contain a forward slash (for logfile naming purposes)
- must not contain contiguous spaces */
int valid_nick(uint8_t *nick);
int valid_nick(char *nick);
/* gets base file name from path or original file name if no path is supplied */
void get_file_name(uint8_t *namebuf, const uint8_t *pathname);
void get_file_name(char *namebuf, const char *pathname);
/* converts str to all lowercase */
void str_to_lower(uint8_t *str);
void str_to_lower(char *str);
#endif /* #define _misc_tools_h */

View File

@ -36,15 +36,15 @@
#include "input.h"
#include "help.h"
uint8_t pending_frnd_requests[MAX_FRIENDS_NUM][TOX_CLIENT_ID_SIZE] = {0};
uint8_t num_frnd_requests = 0;
char pending_frnd_requests[MAX_FRIENDS_NUM][TOX_CLIENT_ID_SIZE];
uint16_t num_frnd_requests = 0;
extern ToxWindow *prompt;
struct _Winthread Winthread;
extern struct user_settings *user_settings;
/* Array of global command names used for tab completion. */
const uint8_t glob_cmd_list[AC_NUM_GLOB_COMMANDS][MAX_CMDNAME_SIZE] = {
const char glob_cmd_list[AC_NUM_GLOB_COMMANDS][MAX_CMDNAME_SIZE] = {
{ "/accept" },
{ "/add" },
{ "/clear" },
@ -70,7 +70,7 @@ const uint8_t glob_cmd_list[AC_NUM_GLOB_COMMANDS][MAX_CMDNAME_SIZE] = {
};
/* Updates own nick in prompt statusbar */
void prompt_update_nick(ToxWindow *prompt, uint8_t *nick, uint16_t len)
void prompt_update_nick(ToxWindow *prompt, char *nick)
{
StatusBar *statusbar = prompt->stb;
snprintf(statusbar->nick, sizeof(statusbar->nick), "%s", nick);
@ -78,7 +78,7 @@ void prompt_update_nick(ToxWindow *prompt, uint8_t *nick, uint16_t len)
}
/* Updates own statusmessage in prompt statusbar */
void prompt_update_statusmessage(ToxWindow *prompt, uint8_t *statusmsg, uint16_t len)
void prompt_update_statusmessage(ToxWindow *prompt, char *statusmsg)
{
StatusBar *statusbar = prompt->stb;
snprintf(statusbar->statusmsg, sizeof(statusbar->statusmsg), "%s", statusmsg);
@ -101,7 +101,7 @@ void prompt_update_connectionstatus(ToxWindow *prompt, bool is_connected)
/* Adds friend request to pending friend requests.
Returns request number on success, -1 if queue is full or other error. */
static int add_friend_request(const uint8_t *public_key)
static int add_friend_request(const char *public_key)
{
if (num_frnd_requests >= MAX_FRIENDS_NUM)
return -1;
@ -169,7 +169,7 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
} else if (key == '\n') {
rm_trailing_spaces_buf(ctx);
uint8_t line[MAX_STR_SIZE] = {0};
char line[MAX_STR_SIZE] = {0};
if (wcs_to_mbs_buf(line, ctx->line, MAX_STR_SIZE) == -1)
memset(&line, 0, sizeof(line));
@ -207,7 +207,7 @@ static void prompt_onDraw(ToxWindow *self, Tox *m)
if (statusbar->is_online) {
int colour = WHITE;
const uint8_t *status_text = "Unknown";
const char *status_text = "Unknown";
switch (statusbar->status) {
case TOX_USERSTATUS_NONE:
@ -252,6 +252,8 @@ static void prompt_onDraw(ToxWindow *self, Tox *m)
int y, x;
getyx(self->window, y, x);
(void) x;
int new_x = ctx->start ? x2 - 1 : ctx->pos;
wmove(self->window, y + 1, new_x);
@ -268,8 +270,8 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int32_t friendnum
ChatContext *ctx = self->chatwin;
uint8_t nick[TOX_MAX_NAME_LENGTH] = {0};
int n_len = tox_get_name(m, friendnum, nick);
char nick[TOX_MAX_NAME_LENGTH];
int n_len = tox_get_name(m, friendnum, (uint8_t *) nick);
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH - 1);
if (!nick[0]) {
@ -279,9 +281,9 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int32_t friendnum
nick[n_len] = '\0';
uint8_t timefrmt[TIME_STR_SIZE];
char timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt, sizeof(timefrmt));
uint8_t *msg;
char *msg;
if (status == 1) {
msg = "has come online";
@ -295,15 +297,15 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int32_t friendnum
}
}
static void prompt_onFriendRequest(ToxWindow *self, Tox *m, const uint8_t *key, const uint8_t *data,
static void prompt_onFriendRequest(ToxWindow *self, Tox *m, const char *key, const char *data,
uint16_t length)
{
ChatContext *ctx = self->chatwin;
uint8_t timefrmt[TIME_STR_SIZE];
char timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt, sizeof(timefrmt));
uint8_t msg[MAX_STR_SIZE];
char msg[MAX_STR_SIZE];
snprintf(msg, sizeof(msg), "Friend request with the message '%s'", data);
line_info_add(self, timefrmt, NULL, NULL, msg, SYS_MSG, 0, 0);
write_to_log(msg, "", ctx->log, true);
@ -311,7 +313,7 @@ static void prompt_onFriendRequest(ToxWindow *self, Tox *m, const uint8_t *key,
int n = add_friend_request(key);
if (n == -1) {
uint8_t *errmsg = "Friend request queue is full. Discarding request.";
char *errmsg = "Friend request queue is full. Discarding request.";
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
write_to_log(errmsg, "", ctx->log, true);
return;
@ -326,18 +328,19 @@ void prompt_init_statusbar(ToxWindow *self, Tox *m)
{
int x2, y2;
getmaxyx(self->window, y2, x2);
(void) y2;
/* Init statusbar info */
StatusBar *statusbar = self->stb;
statusbar->status = TOX_USERSTATUS_NONE;
statusbar->is_online = false;
uint8_t nick[TOX_MAX_NAME_LENGTH];
uint8_t statusmsg[MAX_STR_SIZE];
char nick[TOX_MAX_NAME_LENGTH];
char statusmsg[MAX_STR_SIZE];
pthread_mutex_lock(&Winthread.lock);
uint16_t n_len = tox_get_self_name(m, nick);
uint16_t s_len = tox_get_self_status_message(m, statusmsg, MAX_STR_SIZE);
uint16_t n_len = tox_get_self_name(m, (uint8_t *) nick);
uint16_t s_len = tox_get_self_status_message(m, (uint8_t *) statusmsg, MAX_STR_SIZE);
uint8_t status = tox_get_self_user_status(m);
pthread_mutex_unlock(&Winthread.lock);
@ -345,9 +348,9 @@ void prompt_init_statusbar(ToxWindow *self, Tox *m)
statusmsg[s_len] = '\0';
/* load prev status message or show toxic version if it has never been set */
uint8_t ver[strlen(TOXICVER) + 1];
char ver[strlen(TOXICVER) + 1];
strcpy(ver, TOXICVER);
const uint8_t *toxic_ver = strtok(ver, "_");
const char *toxic_ver = strtok(ver, "_");
if ( (!strcmp("Online", statusmsg) || !strncmp("Toxing on Toxic", statusmsg, 15)) && toxic_ver != NULL) {
snprintf(statusmsg, MAX_STR_SIZE, "Toxing on Toxic v.%s", toxic_ver);
@ -355,9 +358,9 @@ void prompt_init_statusbar(ToxWindow *self, Tox *m)
statusmsg[s_len] = '\0';
}
prompt_update_statusmessage(prompt, statusmsg, s_len);
prompt_update_statusmessage(prompt, statusmsg);
prompt_update_status(prompt, status);
prompt_update_nick(prompt, nick, n_len);
prompt_update_nick(prompt, nick);
/* Init statusbar subwindow */
statusbar->topline = subwin(self->window, 2, x2, 0, 0);
@ -365,8 +368,6 @@ void prompt_init_statusbar(ToxWindow *self, Tox *m)
static void print_welcome_msg(ToxWindow *self)
{
ChatContext *ctx = self->chatwin;
line_info_add(self, NULL, NULL, NULL, " _____ _____ _____ ____ ", SYS_MSG, 1, BLUE);
line_info_add(self, NULL, NULL, NULL, " |_ _/ _ \\ \\/ /_ _/ ___|", SYS_MSG, 1, BLUE);
line_info_add(self, NULL, NULL, NULL, " | || | | \\ / | | | ", SYS_MSG, 1, BLUE);
@ -374,7 +375,7 @@ static void print_welcome_msg(ToxWindow *self)
line_info_add(self, NULL, NULL, NULL, " |_| \\___/_/\\_\\___\\____|", SYS_MSG, 1, BLUE);
line_info_add(self, NULL, NULL, NULL, "", SYS_MSG, 0, 0);
uint8_t *msg = "Welcome to Toxic, a free, open source Tox-based instant messenging client.";
char *msg = "Welcome to Toxic, a free, open source Tox-based instant messenging client.";
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
msg = "Type \"/help\" for assistance. Further help may be found via the man page.";
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN);
@ -400,8 +401,8 @@ static void prompt_onInit(ToxWindow *self, Tox *m)
line_info_init(ctx->hst);
if (user_settings->autolog == AUTOLOG_ON) {
uint8_t myid[TOX_FRIEND_ADDRESS_SIZE];
tox_get_address(m, myid);
char myid[TOX_FRIEND_ADDRESS_SIZE];
tox_get_address(m, (uint8_t *) myid);
log_enable(self->name, myid, ctx->log);
}

View File

@ -35,8 +35,8 @@
ToxWindow new_prompt(void);
void prep_prompt_win(void);
void prompt_init_statusbar(ToxWindow *self, Tox *m);
void prompt_update_nick(ToxWindow *prompt, uint8_t *nick, uint16_t len);
void prompt_update_statusmessage(ToxWindow *prompt, uint8_t *statusmsg, uint16_t len);
void prompt_update_nick(ToxWindow *prompt, char *nick);
void prompt_update_statusmessage(ToxWindow *prompt, char *statusmsg);
void prompt_update_status(ToxWindow *prompt, uint8_t status);
void prompt_update_connectionstatus(ToxWindow *prompt, bool is_connected);

View File

@ -224,10 +224,10 @@ static struct _toxNodes {
int lines;
char nodes[MAXNODES][NODELEN];
uint16_t ports[MAXNODES];
uint8_t keys[MAXNODES][TOX_CLIENT_ID_SIZE];
char keys[MAXNODES][TOX_CLIENT_ID_SIZE];
} toxNodes;
static int nodelist_load(char *filename)
static int nodelist_load(const char *filename)
{
if (!filename)
return 1;
@ -253,7 +253,7 @@ static int nodelist_load(char *filename)
toxNodes.nodes[toxNodes.lines][NODELEN - 1] = 0;
toxNodes.ports[toxNodes.lines] = htons(atoi(port));
uint8_t *key_binary = hex_string_to_bin(key_ascii);
char *key_binary = hex_string_to_bin(key_ascii);
memcpy(toxNodes.keys[toxNodes.lines], key_binary, TOX_CLIENT_ID_SIZE);
free(key_binary);
@ -273,7 +273,7 @@ static int nodelist_load(char *filename)
int init_connection_helper(Tox *m, int line)
{
return tox_bootstrap_from_address(m, toxNodes.nodes[line], TOX_ENABLE_IPV6_DEFAULT,
toxNodes.ports[line], toxNodes.keys[line]);
toxNodes.ports[line], (uint8_t *) toxNodes.keys[line]);
}
/* Connects to a random DHT node listed in the DHTnodes file
@ -329,7 +329,7 @@ int init_connection(Tox *m)
static void do_connection(Tox *m, ToxWindow *prompt)
{
uint8_t msg[MAX_STR_SIZE] = {0};
char msg[MAX_STR_SIZE] = {0};
static int conn_err = 0;
static bool was_connected = false;
@ -388,8 +388,8 @@ int store_data(Tox *m, char *path)
return 1;
FILE *fd;
size_t len;
uint8_t *buf;
int len;
char *buf;
len = tox_size(m);
buf = malloc(len);
@ -397,7 +397,7 @@ int store_data(Tox *m, char *path)
if (buf == NULL)
return 2;
tox_save(m, buf);
tox_save(m, (uint8_t *) buf);
fd = fopen(path, "wb");
@ -423,8 +423,8 @@ static void load_data(Tox *m, char *path)
return;
FILE *fd;
size_t len;
uint8_t *buf;
int len;
char *buf;
if ((fd = fopen(path, "rb")) != NULL) {
fseek(fd, 0, SEEK_END);
@ -444,7 +444,7 @@ static void load_data(Tox *m, char *path)
exit_toxic_err("failed in load_data", FATALERR_FREAD);
}
tox_load(m, buf, len);
tox_load(m, (uint8_t *) buf, len);
load_friendlist(m);
free(buf);
@ -618,7 +618,7 @@ int main(int argc, char *argv[])
if (pthread_create(&Winthread.tid, NULL, thread_winref, (void *) m) != 0)
exit_toxic_err("failed in main", FATALERR_THREAD_CREATE);
uint8_t *msg;
char *msg;
#ifdef _SUPPORT_AUDIO

View File

@ -183,19 +183,19 @@ int complete_line(ChatContext *ctx, const void *list, int n_items, int size)
if (ctx->pos <= 0 || ctx->len <= 0 || ctx->len >= MAX_STR_SIZE)
return -1;
const uint8_t *L = (uint8_t *) list;
const char *L = (char *) list;
uint8_t ubuf[MAX_STR_SIZE];
char ubuf[MAX_STR_SIZE];
/* work with multibyte string copy of buf for simplicity */
if (wcs_to_mbs_buf(ubuf, ctx->line, MAX_STR_SIZE) == -1)
if (wcs_to_mbs_buf(ubuf, ctx->line, sizeof(ubuf)) == -1)
return -1;
/* isolate substring from space behind pos to pos */
uint8_t tmp[MAX_STR_SIZE];
char tmp[MAX_STR_SIZE];
snprintf(tmp, sizeof(tmp), "%s", ubuf);
tmp[ctx->pos] = '\0';
uint8_t *sub = strrchr(tmp, ' ');
char *sub = strrchr(tmp, ' ');
int n_endchrs = 1; /* 1 = append space to end of match, 2 = append ": " */
if (!sub++) {
@ -209,7 +209,7 @@ int complete_line(ChatContext *ctx, const void *list, int n_items, int size)
return -1;
int s_len = strlen(sub);
const uint8_t *match;
const char *match;
bool is_match = false;
int i;
@ -217,7 +217,7 @@ int complete_line(ChatContext *ctx, const void *list, int n_items, int size)
for (i = 0; i < n_items; ++i) {
match = &L[i * size];
if (is_match = strncasecmp(match, sub, s_len) == 0)
if ((is_match = strncasecmp(match, sub, s_len) == 0))
break;
}
@ -225,7 +225,7 @@ int complete_line(ChatContext *ctx, const void *list, int n_items, int size)
return -1;
/* put match in correct spot in buf and append endchars (space or ": ") */
const uint8_t *endchrs = n_endchrs == 1 ? " " : ": ";
const char *endchrs = n_endchrs == 1 ? " " : ": ";
int m_len = strlen(match);
int strt = ctx->pos - s_len;
int diff = m_len - s_len + n_endchrs;
@ -233,7 +233,7 @@ int complete_line(ChatContext *ctx, const void *list, int n_items, int size)
if (ctx->len + diff > MAX_STR_SIZE)
return -1;
uint8_t tmpend[MAX_STR_SIZE];
char tmpend[MAX_STR_SIZE];
strcpy(tmpend, &ubuf[ctx->pos]);
strcpy(&ubuf[strt], match);
strcpy(&ubuf[strt + m_len], endchrs);

View File

@ -49,7 +49,7 @@ void on_request(Tox *m, const uint8_t *public_key, const uint8_t *data, uint16_t
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i].onFriendRequest != NULL)
windows[i].onFriendRequest(&windows[i], m, public_key, data, length);
windows[i].onFriendRequest(&windows[i], m, (const char *) public_key, (const char *) data, length);
}
}
@ -79,7 +79,7 @@ void on_message(Tox *m, int32_t friendnumber, const uint8_t *string, uint16_t le
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i].onMessage != NULL)
windows[i].onMessage(&windows[i], m, friendnumber, string, length);
windows[i].onMessage(&windows[i], m, friendnumber, (const char *) string, length);
}
}
@ -89,7 +89,7 @@ void on_action(Tox *m, int32_t friendnumber, const uint8_t *string, uint16_t len
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i].onAction != NULL)
windows[i].onAction(&windows[i], m, friendnumber, string, length);
windows[i].onAction(&windows[i], m, friendnumber, (const char *) string, length);
}
}
@ -102,7 +102,7 @@ void on_nickchange(Tox *m, int32_t friendnumber, const uint8_t *string, uint16_t
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i].onNickChange != NULL)
windows[i].onNickChange(&windows[i], m, friendnumber, string, length);
windows[i].onNickChange(&windows[i], m, friendnumber, (const char *) string, length);
}
if (store_data(m, DATA_FILE))
@ -115,7 +115,7 @@ void on_statusmessagechange(Tox *m, int32_t friendnumber, const uint8_t *string,
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i].onStatusMessageChange != NULL)
windows[i].onStatusMessageChange(&windows[i], friendnumber, string, length);
windows[i].onStatusMessageChange(&windows[i], friendnumber, (const char *) string, length);
}
}
@ -149,7 +149,7 @@ void on_groupmessage(Tox *m, int groupnumber, int peernumber, const uint8_t *mes
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i].onGroupMessage != NULL)
windows[i].onGroupMessage(&windows[i], m, groupnumber, peernumber, message, length);
windows[i].onGroupMessage(&windows[i], m, groupnumber, peernumber, (const char *) message, length);
}
}
@ -160,7 +160,7 @@ void on_groupaction(Tox *m, int groupnumber, int peernumber, const uint8_t *acti
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i].onGroupAction != NULL)
windows[i].onGroupAction(&windows[i], m, groupnumber, peernumber, action, length);
windows[i].onGroupAction(&windows[i], m, groupnumber, peernumber, (const char *) action, length);
}
}
@ -170,7 +170,7 @@ void on_groupinvite(Tox *m, int32_t friendnumber, const uint8_t *group_pub_key,
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i].onGroupInvite != NULL)
windows[i].onGroupInvite(&windows[i], m, friendnumber, group_pub_key);
windows[i].onGroupInvite(&windows[i], m, friendnumber, (const char *) group_pub_key);
}
}
@ -192,7 +192,7 @@ void on_file_sendrequest(Tox *m, int32_t friendnumber, uint8_t filenumber, uint6
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i].onFileSendRequest != NULL)
windows[i].onFileSendRequest(&windows[i], m, friendnumber, filenumber, filesize,
filename, filename_length);
(const char *) filename, filename_length);
}
}
@ -204,7 +204,7 @@ void on_file_control (Tox *m, int32_t friendnumber, uint8_t receive_send, uint8_
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i].onFileControl != NULL)
windows[i].onFileControl(&windows[i], m, friendnumber, receive_send, filenumber,
control_type, data, length);
control_type, (const char *) data, length);
}
}
@ -215,7 +215,7 @@ void on_file_data(Tox *m, int32_t friendnumber, uint8_t filenumber, const uint8_
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i].onFileData != NULL)
windows[i].onFileData(&windows[i], m, friendnumber, filenumber, data, length);
windows[i].onFileData(&windows[i], m, friendnumber, filenumber, (const char *) data, length);
}
}
@ -322,7 +322,7 @@ void on_window_resize(void)
int i;
for (i == 0; i < MAX_WINDOWS_NUM; ++i) {
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (!windows[i].active)
continue;

View File

@ -78,21 +78,21 @@ struct ToxWindow {
void(*onKey)(ToxWindow *, Tox *, wint_t, bool);
void(*onDraw)(ToxWindow *, Tox *);
void(*onInit)(ToxWindow *, Tox *);
void(*onFriendRequest)(ToxWindow *, Tox *, const uint8_t *, const uint8_t *, uint16_t);
void(*onFriendRequest)(ToxWindow *, Tox *, const char *, const char *, uint16_t);
void(*onFriendAdded)(ToxWindow *, Tox *, int32_t, bool);
void(*onConnectionChange)(ToxWindow *, Tox *, int32_t, uint8_t);
void(*onMessage)(ToxWindow *, Tox *, int32_t, const uint8_t *, uint16_t);
void(*onNickChange)(ToxWindow *, Tox *, int32_t, const uint8_t *, uint16_t);
void(*onMessage)(ToxWindow *, Tox *, int32_t, const char *, uint16_t);
void(*onNickChange)(ToxWindow *, Tox *, int32_t, const char *, uint16_t);
void(*onStatusChange)(ToxWindow *, Tox *, int32_t, uint8_t);
void(*onStatusMessageChange)(ToxWindow *, int32_t, const uint8_t *, uint16_t);
void(*onAction)(ToxWindow *, Tox *, int32_t, const uint8_t *, uint16_t);
void(*onGroupMessage)(ToxWindow *, Tox *, int, int, const uint8_t *, uint16_t);
void(*onGroupAction)(ToxWindow *, Tox *, int, int, const uint8_t *, uint16_t);
void(*onGroupInvite)(ToxWindow *, Tox *, int32_t, const uint8_t *);
void(*onStatusMessageChange)(ToxWindow *, int32_t, const char *, uint16_t);
void(*onAction)(ToxWindow *, Tox *, int32_t, const char *, uint16_t);
void(*onGroupMessage)(ToxWindow *, Tox *, int, int, const char *, uint16_t);
void(*onGroupAction)(ToxWindow *, Tox *, int, int, const char *, uint16_t);
void(*onGroupInvite)(ToxWindow *, Tox *, int32_t, const char *);
void(*onGroupNamelistChange)(ToxWindow *, Tox *, int, int, uint8_t);
void(*onFileSendRequest)(ToxWindow *, Tox *, int32_t, uint8_t, uint64_t, const uint8_t *, uint16_t);
void(*onFileControl)(ToxWindow *, Tox *, int32_t, uint8_t, uint8_t, uint8_t, const uint8_t *, uint16_t);
void(*onFileData)(ToxWindow *, Tox *, int32_t, uint8_t, const uint8_t *, uint16_t);
void(*onFileSendRequest)(ToxWindow *, Tox *, int32_t, uint8_t, uint64_t, const char *, uint16_t);
void(*onFileControl)(ToxWindow *, Tox *, int32_t, uint8_t, uint8_t, uint8_t, const char *, uint16_t);
void(*onFileData)(ToxWindow *, Tox *, int32_t, uint8_t, const char *, uint16_t);
void(*onTypingChange)(ToxWindow *, Tox *, int32_t, uint8_t);
#ifdef _SUPPORT_AUDIO
@ -139,9 +139,9 @@ struct ToxWindow {
/* statusbar info holder */
struct StatusBar {
WINDOW *topline;
uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH];
char statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH];
uint16_t statusmsg_len;
uint8_t nick[TOX_MAX_NAME_LENGTH];
char nick[TOX_MAX_NAME_LENGTH];
uint16_t nick_len;
uint8_t status;
bool is_online;