@@ -81,6 +81,7 @@ static void dump_resync(int);
81
81
static void q_resync (char * , struct chanset_t * );
82
82
static void cancel_user_xfer (int , void * );
83
83
static int private_globals_bitmask ();
84
+ static void finish_share (int );
84
85
85
86
#include "share.h"
86
87
@@ -1241,9 +1242,23 @@ static void share_ufsend2(int idx, char *par)
1241
1242
return ;
1242
1243
}
1243
1244
debug1 ("share: share_ufsend2(): len = %i" , len );
1244
- /* 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() */
1245
- // dcc[idx].u.xfer->filename
1246
- // finish_share(idx);
1245
+ char template [] = "/tmp/shareXXXXXXXX" ;
1246
+ int fd ;
1247
+ if ((fd = mkstemp (template )) < 0 ) {
1248
+ putlog (LOG_BOTS , "*" , "share: share_ufsend2(): error mkstemp(): %s" , strerror (errno ));
1249
+ return ;
1250
+ }
1251
+ write (fd , buf , len ); /* TODO: error handling */
1252
+ close (fd );
1253
+ dcc [idx ].u .xfer -> filename = template ;
1254
+ /* The new method has got no extra dcc[] for the file transfer,
1255
+ * so temporarely alter the dcc[] we habe to make share_finish() happy
1256
+ */
1257
+ char host [UHOSTLEN ];
1258
+ strcpy (host , dcc [idx ].host );
1259
+ strcpy (dcc [idx ].host , dcc [idx ].nick );
1260
+ finish_share (idx );
1261
+ strcpy (dcc [idx ].host , host );
1247
1262
debug0 ("share: share_ufsend2(): end" );
1248
1263
}
1249
1264
@@ -1884,10 +1899,12 @@ static void finish_share(int idx)
1884
1899
struct chanset_t * chan ;
1885
1900
int i , j = -1 ;
1886
1901
1887
- for (i = 0 ; i < dcc_total ; i ++ )
1902
+ for (i = 0 ; i < dcc_total ; i ++ ) {
1903
+ printf ("%i %i %s %s %i %i\n" , idx , i , dcc [i ].nick , dcc [idx ].host , dcc [i ].type -> flags , DCT_BOT );
1888
1904
if (!strcasecmp (dcc [i ].nick , dcc [idx ].host ) &&
1889
1905
(dcc [i ].type -> flags & DCT_BOT ))
1890
1906
j = i ;
1907
+ }
1891
1908
if (j == -1 )
1892
1909
return ;
1893
1910
0 commit comments