From 2c94010d6510d6f2d3eb1c1dcbd7a5c9de71eb16 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Wed, 20 Dec 2017 18:10:02 +1100 Subject: [PATCH] Update arcfour example module to use exported dcc_chat_socketread() callback This allows it to actually connect OK, but it's still nonfunctional at the moment. --- Changelog | 3 +++ dll/arcfour/arcfour.c | 9 ++++++--- dll/arcfour/arcfour.h | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Changelog b/Changelog index b2c9f6d..2be2115 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,8 @@ [Changes 1.2.2] +* Update arcfour example module to use exported dcc_chat_socketread() + callback. (caf) + * Export dcc_chat_socketread() and dcc_send_socketread() callbacks to modules, so that modules implementing new DCC types can use these. (caf) diff --git a/dll/arcfour/arcfour.c b/dll/arcfour/arcfour.c index 28df937..de49c54 100644 --- a/dll/arcfour/arcfour.c +++ b/dll/arcfour/arcfour.c @@ -120,7 +120,7 @@ int Arcfour_Init(IrcCommandDll **intp, Function_ptr *global_table) { initialize_module("arcfour"); memset(keyboxes, 0, sizeof(keyboxes)); - typenum = add_dcc_bind("SCHAT", "schat", NULL, start_dcc_crypt, get_dcc_encrypt, send_dcc_encrypt, end_dcc_crypt); + typenum = add_dcc_bind("SCHAT", "schat", NULL, start_dcc_crypt, dcc_schat_input, send_dcc_encrypt, end_dcc_crypt); add_module_proc(DCC_PROC, "schat", "schat", "Secure DCC Chat", 0, 0, dcc_sdcc, NULL); return 0; } @@ -163,7 +163,7 @@ static int send_dcc_encrypt (int type, int sock, char *buf, int len) return -1; } -static int get_dcc_encrypt (int type, int sock, char *buf, int parm, int len) +static int dcc_schat_input (int type, int sock, char *buf, int parm, int len) { if (type == DCC_CHAT) { if ((len = dgets(buf, sock, parm, BIG_BUFFER_SIZE, NULL)) > 0) { @@ -245,7 +245,10 @@ SocketList *sa; new_s = accept(s, (struct sockaddr *) &remaddr, &sra); type = flags & DCC_TYPES; n = get_socketinfo(s); - if ((add_socketread(new_s, ntohs(remaddr.sin_port), flags, nick, get_dcc_encrypt, NULL)) < 0) + + /* This uses the ordinary dcc_chat_socketread() function - it will call our + * input filter function dcc_schat_input(). */ + if ((add_socketread(new_s, ntohs(remaddr.sin_port), flags, nick, dcc_chat_socketread, NULL)) < 0) { erase_dcc_info(s, 0, "%s", convert_output_format("$G %RDCC error: accept() failed. punt!!", NULL, NULL)); close_socketread(s); diff --git a/dll/arcfour/arcfour.h b/dll/arcfour/arcfour.h index 3491eb0..f934085 100644 --- a/dll/arcfour/arcfour.h +++ b/dll/arcfour/arcfour.h @@ -8,7 +8,7 @@ typedef struct { static inline void arcfourInit(arckey *, void *, unsigned short); static inline char *arcfourCrypt(arckey *, char *, int); static int send_dcc_encrypt (int, int, char *, int); -static int get_dcc_encrypt (int, int, char *, int, int); +static int dcc_schat_input (int, int, char *, int, int); static int start_dcc_crypt (int, int, unsigned long, int); static int end_dcc_crypt (int, unsigned long, int); void dcc_sdcc (char *, char *);