mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-26 22:53:28 +01:00
This should fix segfault and remove one-line comments
This commit is contained in:
parent
7c63bd80d6
commit
ed3e9b476d
@ -50,16 +50,16 @@ struct _ASettings {
|
|||||||
} ASettins;
|
} ASettins;
|
||||||
|
|
||||||
|
|
||||||
void *callback_recv_invite ( void *arg );
|
void callback_recv_invite ( void *arg );
|
||||||
void *callback_recv_ringing ( void *arg );
|
void callback_recv_ringing ( void *arg );
|
||||||
void *callback_recv_starting ( void *arg );
|
void callback_recv_starting ( void *arg );
|
||||||
void *callback_recv_ending ( void *arg );
|
void callback_recv_ending ( void *arg );
|
||||||
void *callback_recv_error ( void *arg );
|
void callback_recv_error ( void *arg );
|
||||||
void *callback_call_started ( void *arg );
|
void callback_call_started ( void *arg );
|
||||||
void *callback_call_canceled ( void *arg );
|
void callback_call_canceled ( void *arg );
|
||||||
void *callback_call_rejected ( void *arg );
|
void callback_call_rejected ( void *arg );
|
||||||
void *callback_call_ended ( void *arg );
|
void callback_call_ended ( void *arg );
|
||||||
void *callback_requ_timeout ( void *arg );
|
void callback_requ_timeout ( void *arg );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -327,57 +327,48 @@ int stop_transmission()
|
|||||||
#define CB_BODY(Arg, onFunc) do { ToxWindow* windows = (Arg); int i;\
|
#define CB_BODY(Arg, onFunc) do { ToxWindow* windows = (Arg); int i;\
|
||||||
for (i = 0; i < MAX_WINDOWS_NUM; ++i) if (windows[i].onFunc != NULL) windows[i].onFunc(&windows[i], ASettins.av); } while (0)
|
for (i = 0; i < MAX_WINDOWS_NUM; ++i) if (windows[i].onFunc != NULL) windows[i].onFunc(&windows[i], ASettins.av); } while (0)
|
||||||
|
|
||||||
void *callback_recv_invite ( void* arg )
|
void callback_recv_invite ( void* arg )
|
||||||
{
|
{
|
||||||
CB_BODY(arg, onInvite);
|
CB_BODY(arg, onInvite);
|
||||||
_cbend;
|
|
||||||
}
|
}
|
||||||
void *callback_recv_ringing ( void* arg )
|
void callback_recv_ringing ( void* arg )
|
||||||
{
|
{
|
||||||
CB_BODY(arg, onRinging);
|
CB_BODY(arg, onRinging);
|
||||||
_cbend;
|
|
||||||
}
|
}
|
||||||
void *callback_recv_starting ( void* arg )
|
void callback_recv_starting ( void* arg )
|
||||||
{
|
{
|
||||||
CB_BODY(arg, onStarting);
|
CB_BODY(arg, onStarting);
|
||||||
_cbend;
|
|
||||||
}
|
}
|
||||||
void *callback_recv_ending ( void* arg )
|
void callback_recv_ending ( void* arg )
|
||||||
{
|
{
|
||||||
CB_BODY(arg, onEnding);
|
CB_BODY(arg, onEnding);
|
||||||
stop_transmission();
|
stop_transmission();
|
||||||
}
|
}
|
||||||
void *callback_recv_error ( void* arg )
|
void callback_recv_error ( void* arg )
|
||||||
{
|
{
|
||||||
CB_BODY(arg, onError);
|
CB_BODY(arg, onError);
|
||||||
_cbend;
|
|
||||||
}
|
}
|
||||||
void *callback_call_started ( void* arg )
|
void callback_call_started ( void* arg )
|
||||||
{
|
{
|
||||||
CB_BODY(arg, onStart);
|
CB_BODY(arg, onStart);
|
||||||
_cbend;
|
|
||||||
}
|
}
|
||||||
void *callback_call_canceled ( void* arg )
|
void callback_call_canceled ( void* arg )
|
||||||
{
|
{
|
||||||
CB_BODY(arg, onCancel);
|
CB_BODY(arg, onCancel);
|
||||||
_cbend;
|
|
||||||
}
|
}
|
||||||
void *callback_call_rejected ( void* arg )
|
void callback_call_rejected ( void* arg )
|
||||||
{
|
{
|
||||||
CB_BODY(arg, onReject);
|
CB_BODY(arg, onReject);
|
||||||
_cbend;
|
|
||||||
}
|
}
|
||||||
void *callback_call_ended ( void* arg )
|
void callback_call_ended ( void* arg )
|
||||||
{
|
{
|
||||||
CB_BODY(arg, onEnd);
|
CB_BODY(arg, onEnd);
|
||||||
stop_transmission();
|
stop_transmission();
|
||||||
_cbend;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *callback_requ_timeout ( void* arg )
|
void callback_requ_timeout ( void* arg )
|
||||||
{
|
{
|
||||||
CB_BODY(arg, onTimeout);
|
CB_BODY(arg, onTimeout);
|
||||||
_cbend;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -282,9 +282,9 @@ static void chat_onFileControl(ToxWindow *self, Tox *m, int num, uint8_t receive
|
|||||||
case TOX_FILECONTROL_ACCEPT:
|
case TOX_FILECONTROL_ACCEPT:
|
||||||
wprintw(ctx->history, "File transfer for '%s' accepted.\n", filename);
|
wprintw(ctx->history, "File transfer for '%s' accepted.\n", filename);
|
||||||
break;
|
break;
|
||||||
// case TOX_FILECONTROL_PAUSE:
|
/*case TOX_FILECONTROL_PAUSE:
|
||||||
// wprintw(ctx->history, "File transfer for '%s' paused.\n", filename);
|
wprintw(ctx->history, "File transfer for '%s' paused.\n", filename);
|
||||||
// break;
|
break; */
|
||||||
case TOX_FILECONTROL_KILL:
|
case TOX_FILECONTROL_KILL:
|
||||||
wprintw(ctx->history, "File transfer for '%s' failed.\n", filename);
|
wprintw(ctx->history, "File transfer for '%s' failed.\n", filename);
|
||||||
|
|
||||||
|
@ -79,8 +79,8 @@ static struct cmd_func chat_commands[] = {
|
|||||||
static int parse_command(WINDOW *w, char *cmd, char (*args)[MAX_STR_SIZE])
|
static int parse_command(WINDOW *w, char *cmd, char (*args)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
int num_args = 0;
|
int num_args = 0;
|
||||||
bool cmd_end = false; // flags when we get to the end of cmd
|
bool cmd_end = false; /* flags when we get to the end of cmd */
|
||||||
char *end; // points to the end of the current arg
|
char *end; /* points to the end of the current arg */
|
||||||
|
|
||||||
/* characters wrapped in double quotes count as one arg */
|
/* characters wrapped in double quotes count as one arg */
|
||||||
while (!cmd_end && num_args < MAX_NUM_ARGS) {
|
while (!cmd_end && num_args < MAX_NUM_ARGS) {
|
||||||
|
@ -472,7 +472,7 @@ static void friendlist_onInit(ToxWindow *self, Tox *m)
|
|||||||
static void friendlist_onAv(ToxWindow *self, ToxAv *av)
|
static void friendlist_onAv(ToxWindow *self, ToxAv *av)
|
||||||
{
|
{
|
||||||
int id = toxav_get_peer_id(av, 0);
|
int id = toxav_get_peer_id(av, 0);
|
||||||
id++;
|
/*id++;*/
|
||||||
if ( id >= max_friends_index)
|
if ( id >= max_friends_index)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -511,7 +511,7 @@ ToxWindow new_friendlist(void)
|
|||||||
ret.onFriendAdded = &friendlist_onFriendAdded;
|
ret.onFriendAdded = &friendlist_onFriendAdded;
|
||||||
ret.onMessage = &friendlist_onMessage;
|
ret.onMessage = &friendlist_onMessage;
|
||||||
ret.onConnectionChange = &friendlist_onConnectionChange;
|
ret.onConnectionChange = &friendlist_onConnectionChange;
|
||||||
ret.onAction = &friendlist_onMessage; // Action has identical behaviour to message
|
ret.onAction = &friendlist_onMessage; /* Action has identical behaviour to message */
|
||||||
ret.onNickChange = &friendlist_onNickChange;
|
ret.onNickChange = &friendlist_onNickChange;
|
||||||
ret.onStatusChange = &friendlist_onStatusChange;
|
ret.onStatusChange = &friendlist_onStatusChange;
|
||||||
ret.onStatusMessageChange = &friendlist_onStatusMessageChange;
|
ret.onStatusMessageChange = &friendlist_onStatusMessageChange;
|
||||||
|
@ -330,13 +330,13 @@ static void send_group_action(ToxWindow *self, ChatContext *ctx, Tox *m, uint8_t
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// uint8_t selfname[TOX_MAX_NAME_LENGTH];
|
/* uint8_t selfname[TOX_MAX_NAME_LENGTH];
|
||||||
// tox_get_self_name(m, selfname, TOX_MAX_NAME_LENGTH);
|
tox_get_self_name(m, selfname, TOX_MAX_NAME_LENGTH);
|
||||||
|
|
||||||
// print_time(ctx->history);
|
print_time(ctx->history);
|
||||||
// wattron(ctx->history, COLOR_PAIR(YELLOW));
|
wattron(ctx->history, COLOR_PAIR(YELLOW));
|
||||||
// wprintw(ctx->history, "* %s %s\n", selfname, action);
|
wprintw(ctx->history, "* %s %s\n", selfname, action);
|
||||||
// wattroff(ctx->history, COLOR_PAIR(YELLOW));
|
wattroff(ctx->history, COLOR_PAIR(YELLOW)); */
|
||||||
|
|
||||||
if (tox_group_action_send(m, self->num, action, strlen(action) + 1) == -1) {
|
if (tox_group_action_send(m, self->num, action, strlen(action) + 1) == -1) {
|
||||||
wattron(ctx->history, COLOR_PAIR(RED));
|
wattron(ctx->history, COLOR_PAIR(RED));
|
||||||
|
@ -158,7 +158,7 @@ static Tox *init_tox(int ipv4)
|
|||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
tox_set_name(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux"));
|
tox_set_name(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux"));
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
tox_set_name(m, (uint8_t *) "Hipster", sizeof("Hipster")); //This used to users of other Unixes are hipsters
|
tox_set_name(m, (uint8_t *) "Hipster", sizeof("Hipster")); /* This used to users of other Unixes are hipsters */
|
||||||
#else
|
#else
|
||||||
tox_set_name(m, (uint8_t *) "Registered Minix user #4", sizeof("Registered Minix user #4"));
|
tox_set_name(m, (uint8_t *) "Registered Minix user #4", sizeof("Registered Minix user #4"));
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
extern ToxWindow *prompt;
|
extern ToxWindow *prompt;
|
||||||
|
|
||||||
// XXX: FIX
|
/* XXX: FIX */
|
||||||
unsigned char *hex_string_to_bin(char hex_string[])
|
unsigned char *hex_string_to_bin(char hex_string[])
|
||||||
{
|
{
|
||||||
size_t len = strlen(hex_string);
|
size_t len = strlen(hex_string);
|
||||||
@ -224,13 +224,13 @@ void get_file_name(uint8_t *pathname, uint8_t *namebuf)
|
|||||||
while (idx >= 0 && pathname[idx] == '/')
|
while (idx >= 0 && pathname[idx] == '/')
|
||||||
pathname[idx--] = '\0';
|
pathname[idx--] = '\0';
|
||||||
|
|
||||||
uint8_t *filename = strrchr(pathname, '/'); // Try unix style paths
|
uint8_t *filename = strrchr(pathname, '/'); /* Try unix style paths */
|
||||||
|
|
||||||
if (filename != NULL) {
|
if (filename != NULL) {
|
||||||
if (!strlen(++filename))
|
if (!strlen(++filename))
|
||||||
filename = pathname;
|
filename = pathname;
|
||||||
} else {
|
} else {
|
||||||
filename = strrchr(pathname, '\\'); // Try windows style paths
|
filename = strrchr(pathname, '\\'); /* Try windows style paths */
|
||||||
|
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
filename = pathname;
|
filename = pathname;
|
||||||
|
@ -430,7 +430,7 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int friendnum , u
|
|||||||
|
|
||||||
static void prompt_onFriendRequest(ToxWindow *self, uint8_t *key, uint8_t *data, uint16_t length)
|
static void prompt_onFriendRequest(ToxWindow *self, uint8_t *key, uint8_t *data, uint16_t length)
|
||||||
{
|
{
|
||||||
// make sure message data is null-terminated
|
/* make sure message data is null-terminated */
|
||||||
data[length - 1] = 0;
|
data[length - 1] = 0;
|
||||||
PromptBuf *prt = self->promptbuf;
|
PromptBuf *prt = self->promptbuf;
|
||||||
prep_prompt_win();
|
prep_prompt_win();
|
||||||
|
@ -82,7 +82,7 @@ enum {
|
|||||||
|
|
||||||
/* Fixes text color problem on some terminals.
|
/* Fixes text color problem on some terminals.
|
||||||
Uncomment if necessary */
|
Uncomment if necessary */
|
||||||
//#define URXVT_FIX
|
/* #define URXVT_FIX */
|
||||||
|
|
||||||
typedef struct ToxWindow ToxWindow;
|
typedef struct ToxWindow ToxWindow;
|
||||||
typedef struct StatusBar StatusBar;
|
typedef struct StatusBar StatusBar;
|
||||||
|
@ -253,7 +253,7 @@ int add_window(Tox *m, ToxWindow w)
|
|||||||
/* Deletes window w and cleans up */
|
/* Deletes window w and cleans up */
|
||||||
void del_window(ToxWindow *w)
|
void del_window(ToxWindow *w)
|
||||||
{
|
{
|
||||||
active_window = windows; // Go to prompt screen
|
active_window = windows; /* Go to prompt screen */
|
||||||
|
|
||||||
delwin(w->window);
|
delwin(w->window);
|
||||||
memset(w, 0, sizeof(ToxWindow));
|
memset(w, 0, sizeof(ToxWindow));
|
||||||
@ -279,7 +279,7 @@ void set_next_window(int ch)
|
|||||||
if (active_window->window)
|
if (active_window->window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (active_window == inf) { // infinite loop check
|
if (active_window == inf) { /* infinite loop check */
|
||||||
endwin();
|
endwin();
|
||||||
fprintf(stderr, "set_next_window() failed. Aborting...\n");
|
fprintf(stderr, "set_next_window() failed. Aborting...\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
Loading…
Reference in New Issue
Block a user