From 0ade9d80ba59224fc97a6b7d3d7d332298687b6d Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Tue, 25 Jun 2024 03:39:57 +0200 Subject: [PATCH] Proof of concept - Userlist transfer complete; switched over. --- src/mod/share.mod/share.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/mod/share.mod/share.c b/src/mod/share.mod/share.c index 7045b377d..b030586c4 100644 --- a/src/mod/share.mod/share.c +++ b/src/mod/share.mod/share.c @@ -81,6 +81,7 @@ static void dump_resync(int); static void q_resync(char *, struct chanset_t *); static void cancel_user_xfer(int, void *); static int private_globals_bitmask(); +static void finish_share(int); #include "share.h" @@ -1241,9 +1242,23 @@ static void share_ufsend2(int idx, char *par) return; } debug1("share: share_ufsend2(): len = %i", len); - /* TODO: da weiter wo auch der alte mechanismus weitermacht und feature funcs zu callen und userfile zu loaden. das passiert im anderen fall ueber transfer.c eof_dcc_send() -> share.c finish_share() */ - // dcc[idx].u.xfer->filename - // finish_share(idx); + char template[] = "/tmp/shareXXXXXXXX"; + int fd; + if ((fd = mkstemp(template)) < 0) { + putlog(LOG_BOTS, "*", "share: share_ufsend2(): error mkstemp(): %s", strerror(errno)); + return; + } + write(fd, buf, len); /* TODO: error handling */ + close(fd); + dcc[idx].u.xfer->filename = template; + /* The new method has got no extra dcc[] for the file transfer, + * so temporarely alter the dcc[] we habe to make share_finish() happy + */ + char host[UHOSTLEN]; + strcpy(host, dcc[idx].host); + strcpy(dcc[idx].host, dcc[idx].nick); + finish_share(idx); + strcpy(dcc[idx].host, host); debug0("share: share_ufsend2(): end"); } @@ -1884,10 +1899,12 @@ static void finish_share(int idx) struct chanset_t *chan; int i, j = -1; - for (i = 0; i < dcc_total; i++) + for (i = 0; i < dcc_total; i++) { + printf("%i %i %s %s %i %i\n", idx, i, dcc[i].nick, dcc[idx].host, dcc[i].type->flags, DCT_BOT); if (!strcasecmp(dcc[i].nick, dcc[idx].host) && (dcc[i].type->flags & DCT_BOT)) j = i; + } if (j == -1) return;