mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 21:13:02 +01:00
try to limit scope of globals
This commit is contained in:
parent
7ad520f128
commit
57c2872b75
@ -19,6 +19,9 @@ extern char *DATA_FILE;
|
||||
extern int store_data(Tox *m, char *path);
|
||||
extern int num_groupchats;
|
||||
|
||||
extern FileSender file_senders[MAX_FILES];
|
||||
extern ToxicFriend friends[MAX_FRIENDS_NUM];
|
||||
|
||||
static void chat_onMessage(ToxWindow *self, Tox *m, int num, uint8_t *msg, uint16_t len)
|
||||
{
|
||||
if (self->num != num)
|
||||
|
@ -16,6 +16,11 @@
|
||||
extern ToxWindow *prompt;
|
||||
extern int num_groupchats;
|
||||
|
||||
extern ToxicFriend friends[MAX_FRIENDS_NUM];
|
||||
|
||||
extern FileSender file_senders[MAX_FILES];
|
||||
extern uint8_t max_file_senders_index;
|
||||
|
||||
void cmd_chat_help(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||
{
|
||||
wattron(window, COLOR_PAIR(CYAN) | A_BOLD);
|
||||
|
@ -23,6 +23,7 @@ static int max_friends_index = 0; /* marks the index of the last friend in fr
|
||||
static int num_friends = 0;
|
||||
static int num_selected = 0;
|
||||
|
||||
ToxicFriend friends[MAX_FRIENDS_NUM];
|
||||
static int friendlist_index[MAX_FRIENDS_NUM] = {0};
|
||||
|
||||
static int index_name_cmp(const void *n1, const void *n2)
|
||||
|
@ -3,6 +3,20 @@
|
||||
|
||||
#include "toxic_windows.h"
|
||||
|
||||
typedef struct {
|
||||
uint8_t name[TOX_MAX_NAME_LENGTH];
|
||||
uint16_t namelength;
|
||||
uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH];
|
||||
uint16_t statusmsg_len;
|
||||
uint8_t pending_groupchat[TOX_CLIENT_ID_SIZE];
|
||||
int num;
|
||||
int chatwin;
|
||||
bool active;
|
||||
bool online;
|
||||
TOX_USERSTATUS status;
|
||||
struct FileReceiver file_receiver;
|
||||
} ToxicFriend;
|
||||
|
||||
ToxWindow new_friendlist(void);
|
||||
void disable_chatwin(int f_num);
|
||||
int get_friendnum(uint8_t *name);
|
||||
|
@ -11,12 +11,16 @@
|
||||
|
||||
#include "toxic_windows.h"
|
||||
#include "misc_tools.h"
|
||||
#include "friendlist.h"
|
||||
|
||||
extern char *DATA_FILE;
|
||||
extern ToxWindow *prompt;
|
||||
|
||||
extern ToxicFriend friends[MAX_FRIENDS_NUM];
|
||||
|
||||
extern uint8_t pending_frnd_requests[MAX_FRIENDS_NUM][TOX_CLIENT_ID_SIZE];
|
||||
extern uint8_t num_frnd_requests;
|
||||
|
||||
extern int num_groupchats;
|
||||
|
||||
/* command functions */
|
||||
|
@ -15,15 +15,13 @@
|
||||
#include "misc_tools.h"
|
||||
#include "groupchat.h"
|
||||
|
||||
static GroupChat groupchats[MAX_GROUPCHAT_NUM];
|
||||
static int max_groupchat_index = 0;
|
||||
int num_groupchats = 0;
|
||||
|
||||
ToxWindow new_group_chat(Tox *m, int groupnum);
|
||||
|
||||
extern char *DATA_FILE;
|
||||
extern int store_data(Tox *m, char *path);
|
||||
|
||||
GroupChat groupchats[MAX_GROUPCHAT_NUM];
|
||||
int num_groupchats = 0;
|
||||
static int max_groupchat_index = 0;
|
||||
|
||||
int init_groupchat_win(ToxWindow *prompt, Tox *m, int groupnum)
|
||||
{
|
||||
int i;
|
||||
|
@ -13,3 +13,4 @@ typedef struct {
|
||||
} GroupChat;
|
||||
|
||||
int init_groupchat_win(ToxWindow *prompt, Tox *m, int groupnum);
|
||||
ToxWindow new_group_chat(Tox *m, int groupnum);
|
||||
|
@ -49,6 +49,9 @@ char *DATA_FILE = NULL;
|
||||
char *SRVLIST_FILE = NULL;
|
||||
ToxWindow *prompt = NULL;
|
||||
|
||||
FileSender file_senders[MAX_FILES];
|
||||
uint8_t max_file_senders_index;
|
||||
|
||||
void on_window_resize(int sig)
|
||||
{
|
||||
endwin();
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Toxic -- Tox Curses Client
|
||||
*/
|
||||
|
||||
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
// #define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
|
||||
/* convert a hex string to binary */
|
||||
unsigned char *hex_string_to_bin(char hex_string[]);
|
||||
|
@ -123,9 +123,6 @@ typedef struct {
|
||||
uint64_t timestamp;
|
||||
} FileSender;
|
||||
|
||||
FileSender file_senders[MAX_FILES];
|
||||
uint8_t max_file_senders_index;
|
||||
|
||||
struct FileReceiver {
|
||||
uint8_t filenames[MAX_FILES][MAX_STR_SIZE];
|
||||
bool pending[MAX_FILES];
|
||||
@ -133,22 +130,6 @@ struct FileReceiver {
|
||||
|
||||
/* End file transfer code */
|
||||
|
||||
typedef struct {
|
||||
uint8_t name[TOX_MAX_NAME_LENGTH];
|
||||
uint16_t namelength;
|
||||
uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH];
|
||||
uint16_t statusmsg_len;
|
||||
uint8_t pending_groupchat[TOX_CLIENT_ID_SIZE];
|
||||
int num;
|
||||
int chatwin;
|
||||
bool active;
|
||||
bool online;
|
||||
TOX_USERSTATUS status;
|
||||
struct FileReceiver file_receiver;
|
||||
} ToxicFriend;
|
||||
|
||||
ToxicFriend friends[MAX_FRIENDS_NUM];
|
||||
|
||||
void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata);
|
||||
void on_connectionchange(Tox *m, int friendnumber, uint8_t status, void *userdata);
|
||||
void on_message(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
||||
|
Loading…
Reference in New Issue
Block a user