Introduce a struct dcc_ops to contain all functions pointers for a custom DCC type

Modules now must pass a pointer to a struct dcc_ops when calling add_dcc_bind() instead of
a list of function pointers.
This commit is contained in:
Kevin Easton
2018-02-08 17:48:34 +11:00
parent 64ec300d5d
commit 61a926a766
9 changed files with 73 additions and 82 deletions

View File

@@ -158,8 +158,27 @@ struct dcc_offer {
void init_dcc_table(void);
int BX_remove_all_dcc_binds(char *);
int BX_remove_dcc_bind(char *, int);
/* Function pointers for the operations implementing a DCC type.
* This structure is part of the module ABI - if you change it,
* you need to roll MODULE_VERSION in <module.h>.
*
* .init() is called when a matching DCC offer is received over IRC
* .open() is called when a DCC connection is established
* .input() is called to fetch some data when the socket becomes readable
* .output() is called to write a message to the socket
* .close() is called when the DCC connection is closed
*/
struct dcc_ops
{
int (*init)(const char *, const char *, const char *, const char *, const char *, const char *, unsigned long, unsigned short);
int (*open)(int, int, unsigned long, unsigned short);
int (*input)(int, int, char *, int, int);
int (*output)(int, int, char *, int);
int (*close)(int, unsigned long, unsigned short);
};
int BX_add_dcc_bind(char *, char *, void *, void *, void *, void *, void *);
int BX_add_dcc_bind(char *, char *, const struct dcc_ops *);
/* add_socketread() callbacks for ordinary CHAT and SEND DCCs */
extern void BX_dcc_chat_socketread(int);
extern void BX_dcc_send_socketread(int);

View File

@@ -10,7 +10,7 @@
* if we change the table below, we change this module number to the
* current date (YYYYMMDDxx where xx is a serial number).
*/
#define MODULE_VERSION 2017122001UL
#define MODULE_VERSION 2018020801UL
#include "struct.h"

View File

@@ -604,7 +604,7 @@ extern Function_ptr *global;
#define dcc_create (*(DCC_int *(*)(char *, char *, char *, unsigned long, int, int, unsigned long, void (*)(int)))global[DCC_CREATE_FUNC])
#define find_dcc (*(SocketList *(*)(const char *, const char *, const char *, int, int, int, int))global[FIND_DCC_FUNC])
#define erase_dcc_info (*(void (*)(int, int, char *, ...))global[ERASE_DCC_INFO])
#define add_dcc_bind (*(int (*)(char *, char *, void *, void *, void *, void *, void *))global[ADD_DCC_BIND])
#define add_dcc_bind (*(int (*)(char *, char *, const struct dcc_ops *))global[ADD_DCC_BIND])
#define remove_dcc_bind (*(int (*)(char *, int ))global[REMOVE_DCC_BIND])
#define remove_all_dcc_binds (*(int (*)(char *))global[REMOVE_ALL_DCC_BINDS])
#define get_active_count (*(int (*)(void ))global[GET_ACTIVE_COUNT])