alias file2ram {
; any file, example mirc.exe
tokenize 32 mirc.exe
; free table, if exists
if ($hget($1)) hdel -w $1 *
; read file to hash table (RAM)
var %i = 0, %s = $file($1)
while (%i <= %s) {
bread $1 %i 4096 $+(&,$1)
hadd -mb $1 $calc($hget($1,0).item + 1) $+(&,$1)
bunset $+(&,$1)
inc %i 4096
}
; we have 100% mirc.exe in RAM -> hash table "mirc.exe"
echo -a total $hget($1,0).item pieces, 1 piece <= 4096 bytes
; and now I need to send this file, from RAM by sockets
; sending "mirc.exe" hash table
sendfile $1
}
; ...socket already open
alias sendfile {
; ??? :(
; as lamers example:
var %i = 1
while (%i <= $hget($1,0).item) {
if ($hget($1,%i,$+(&,$1))) {
sockwrite any_sockname $+(&,$1)
bunset $+(&,$1)
}
inc %i
}
; it's not working
; help please! =(
}