proc pub:allentries {nick uhost handle chan arg} {
global cd_release
set totrlsfound 0

foreach database $cd_release {
set rlsfile [open $database r]
while {![eof $rlsfile]} {
set rlsline [gets $rlsfile]

   if {[regexp -nocase {(.*?)=>(.*?)} $rlsline line a b]} {
   lappend entries $a
   incr totrlsfound 1

    }
  }
close $rlsfile
}

set entries $entries

foreach line2 [wordwrap2 $entries 400] {
puthelp "PRIVMSG $nick :Alle vorhandenen Einträge: $line2"
}

if {$totrlsfound == "0" } {puthelp "PRIVMSG $nick :Insgesamt $totrlsfound Einträge vorhanden."}
if {$totrlsfound == "1" } {puthelp "PRIVMSG $nick :Insgesamt $totrlsfound Eintrag vorhanden."}
if {$totrlsfound >= 2 } {puthelp "PRIVMSG $nick :Insgesamt $totrlsfound Einträge vorhanden."}
}

proc wordwrap2 {str {len 300} {splitChr { }}} {
   set out [set cur {}]; set i 0
   foreach word [split [set str][unset str] $splitChr] {
      if {[incr i [string len $word]]>$len} {
         lappend out [join $cur $splitChr]
         set cur [list $word]
         set i [string len $word]
      } {
         lappend cur $word
      }
      incr i
   }
   lappend out [join $cur $splitChr]
}

#####################################################
# the txt file looks like:
#
# word1 => definition
# word2 => definition
# ...
#
#####################################################