#!hs2
#!load hamster.hsm
#!load hmessage.hsm
var ($ind, $imes, $isrv, $pos, $pos2, $lungh, $srvdisp, $srvpub, $LOut)
var ($TempDir, $fileo, $messo, $groupost, $groupserv, $fconf)
var ($serverconn, $group, $server)
$TempDir = HamPath + "Groups\temp_news\"
$serverconn = paramstr(1)
$srvdisp = listalloc()
if ($serverconn != "")
ListAdd ($srvdisp, $serverconn)
endif
$srvpub = iniread("","newsserverpubblici","nomeserver","0")
$pos = 0
Repeat
$pos2 = Pos (",", $srvpub, $pos+1)
if ($pos2 !=0)
$lungh = $pos2-$pos-1
else
$lungh = Len($srvpub)-$pos
endif
ListAdd ($srvdisp, Copy ($srvpub, $pos+1 , $lungh))
$pos = $pos2
Until ($pos = 0)
$Lout = listalloc()
DirMake( $TempDir )
Listfiles( $LOut, HamPath+"Groups\News.out\*.msg", false )
For($imes, 0, ListCount($LOut)-1 )
FileCopy( HamPath + "Groups\News.out\" + ListGet($Lout,$imes), $TempDir _
+ ListGet($Lout,$imes))
FileDelete(HamPath + "Groups\News.out\" + ListGet($Lout,$imes))
endfor
$messo = listalloc()
$fconf = listalloc()
For($isrv, 0, ListCount($srvdisp)-1 )
ListClear($LOut)
Listfiles( $LOut, $TempDir+"\*.msg", false )
For($imes, 0, ListCount($LOut)-1 )
$fileo = ListGet ($Lout, $imes)
ListLoad($messo, $TempDir + $fileo)
$groupost = MsgGetHeader( $messo, "Newsgroups:")
ListLoad($fconf, HamPath + "pulls.hst")
For($ind,0,ListCount($fconf)-1)
$groupserv = ListGet ($fconf, $ind)
if (Pos ($groupost, $groupserv) != 0)
RE_Split ($groupserv, ",", $group, $server)
if ($server = ListGet($srvdisp,$isrv))
print ("posto "+ $groupost+ " su "+ListGet($srvdisp,$isrv))
FileCopy( $TempDir + $fileo, HamPath + "Groups\News.out\" + $fileo)
FileDelete( $TempDir + $fileo)
HamNewsJobsPostDef (ListGet($srvdisp,$isrv)+",nntp")
HamNewsJobsStart
HamWaitIdle
endif
endif
endfor
if ($isrv == ListCount($srvdisp)-1 && FileExists ($TempDir + $fileo))
warning ("Impossibile postare " +$groupost + " perchè sottoscritto su un server" _
+ "di un provider a cui non sei collegato. La spedizione sarà ritentata.")
endif
ListClear($messo)
ListClear($fconf)
endfor
endfor
ListFree($srvdisp)
ListFree($LOut)
ListFree($messo)
ListFree($fconf)
quit