Skip to content

Commit

Permalink
Proof of concept - Userlist transfer complete; switched over.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelortmann committed Jun 25, 2024
1 parent 3c8f1c9 commit 0ade9d8
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/mod/share.mod/share.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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");
}

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 0ade9d8

Please sign in to comment.