From 328837f7c91191445a83707b3ebb9b9e422a08c1 Mon Sep 17 00:00:00 2001 From: jbm Date: Thu, 29 Mar 2001 20:48:37 +0000 Subject: [PATCH] - Thu Mar 29 14:45:22 CST 2001 (jbm) - Add module capability to the 0001/001f stuff (jbm) --- CHANGES | 3 +++ src/login.c | 21 +++++++++++++++++++-- utils/faimtest/faimtest.c | 27 ++++++++++++++++++++++----- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index 93073e3..a5e69fa 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ No release numbers ------------------ + - Thu Mar 29 14:45:22 CST 2001 (jbm) + - Add module capability to the 0001/001f stuff (jbm) + - Wed Mar 28 21:20:08 PST 2001 - Add flags arg to aim_chat_send_im() - Add msglen arg to aim_send_im and aim_chat_send_im diff --git a/src/login.c b/src/login.c index 1fd031a..bb26fed 100644 --- a/src/login.c +++ b/src/login.c @@ -715,14 +715,31 @@ static int memrequest(struct aim_session_t *sess, aim_module_t *mod, struct comm { rxcallback_t userfunc; unsigned long offset, len; + struct aim_tlvlist_t *tlvlist; + struct aim_tlv_t *tlv; + char *modname; offset = aimutil_get32(data); len = aimutil_get32(data+4); - faimdprintf(sess, 1, "data at 0x%08lx (%d bytes) requested\n", offset, len); + if(rx->commandlen > 0x12) { /* XXX right len? */ + tlvlist = aim_readtlvchain(data+8, datalen-8); + + if((tlv = aim_gettlv(tlvlist, 0x0001, 1))) { + modname = malloc(tlv->length + 5); + memset(modname, 0, tlv->length + 5); + memcpy(modname, tlv->value, tlv->length); + strncat(modname, ".ocm", tlv->length + 5 - strlen(modname)); + } else { + modname = "aim.exe"; + } + } else + modname = "aim.exe"; + + faimdprintf(sess, 1, "data at 0x%08lx (%d bytes) of %s requested\n", offset, len, modname); if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) - return userfunc(sess, rx, offset, len); + return userfunc(sess, rx, offset, len, modname); return 0; } diff --git a/utils/faimtest/faimtest.c b/utils/faimtest/faimtest.c index ec10485..bc6656a 100644 --- a/utils/faimtest/faimtest.c +++ b/utils/faimtest/faimtest.c @@ -797,11 +797,26 @@ int faimtest_handleredirect(struct aim_session_t *sess, struct command_rx_struct return 1; } -static int getaimdata(unsigned char *buf, int buflen, unsigned long offset) +static int getaimdata(unsigned char *buf, int buflen, unsigned long offset, char *modname) { FILE *f; - if (!(f = fopen(aimbinarypath, "r"))) { + char *filename; + int len; + + len = strlen(aimbinarypath)+1+strlen(modname)+1; + + if(!(filename = malloc(len))) { + dperror("memrequest: malloc"); + return -1; + } + + memset(filename,0, len); + memcpy(filename, aimbinarypath, strlen(aimbinarypath)); + filename[strlen(filename)] = '/'; + strncat(filename, modname, len - strlen(filename)); + + if (!(f = fopen(filename, "r"))) { dperror("memrequest: fopen"); return -1; } @@ -835,10 +850,12 @@ static int faimtest_memrequest(struct aim_session_t *sess, struct command_rx_str va_list ap; unsigned long offset, len; unsigned char *buf; + char *modname; va_start(ap, command); offset = va_arg(ap, unsigned long); len = va_arg(ap, unsigned long); + modname = va_arg(ap, char *); va_end(ap); if (!(buf = malloc(len))) { @@ -846,15 +863,15 @@ static int faimtest_memrequest(struct aim_session_t *sess, struct command_rx_str return 0; } - if (aimbinarypath && (getaimdata(buf, len, offset) == len)) { + if (aimbinarypath && (getaimdata(buf, len, offset, modname) == len)) { - dvprintf("memrequest: sending %ld bytes from 0x%08lx in %s...\n", len, offset, aimbinarypath); + dvprintf("memrequest: sending %ld bytes from 0x%08lx in \"%s/%s\"...\n", len, offset, aimbinarypath, modname); aim_sendmemblock(sess, command->conn, offset, len, buf); } else { - dprintf("memrequest: unable to use AIM binary, sending defaults...\n"); + dvprintf("memrequest: unable to use AIM binary (\"%s/%s\"), sending defaults...\n", aimbinarypath, modname); aim_sendmemblock(sess, command->conn, offset, len, NULL); -- 2.45.1