[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
generic mapping procedure
Hello,
I dont know if someone finds it useful, but it serves well
for me.
alexis
#
# $Id: map.cf,v 1.1 1997/07/08 09:28:05 alexis Exp $
#
# Generic database facilities.
#
#
# Checks whether target exists and older than the source. Does
# not check if the source exists.
#
uptodate (source, target) {
if [ ! -f $target ]; then
return 1
fi
if [ $source -nt $target ]; then
return 1
fi
return 0
}
#
# Generic database initialization. Establish $map relation with the
# file $file of type $type using $options In case of any error defines
# false lookup function.
#
map (type, name, file, options) {
if [ -f $file ]; then
case $type in
incore)
uptodate $file $file.zmsh || /usr/bin/awk '/^[^#]/{
printf "db add '$name' '\''%s'\'' '\''%s'\''\\n",$1,$2;
}' < $file > $file.zmsh || break
relation -t incore $options $name && . $file.zmsh &&
return 0
;;
btree)
uptodate $file $file.db || /usr/sbin/makemap btree \
$file < $file || break
relation -t btree -f $file.db $options $name && return 0
;;
esac
fi
$name () { return 1 }
return 1
}
--
Yesterday dont matter when its gone