#!/usr/bin/tclsh

#
# This simple routine reads stdin and adds
# it to a gdbm database (usually MemoDB.pui)
#
# This can be used by a mail splitting
# program to send mail messages to the database
# for retrieval upon next "sync".
#

set memo {}
while {[gets stdin line] != -1} {
  append memo "$line\n"
}

load tclpui.so

# Open file for writing
set puidb [puiOpen [lindex $argv 0] w]

# category: unfiled, attribute: "dirty"
set newmemo(category) 0
set newmemo(attribute) 64
set newmemo(text) $memo

# add record
puiWrite $puidb 0 newmemo

puiClose $puidb

exit 0
