#! /bin/bash -posix
#
# -*-sh-*-
#
#     m_palm - Palm address database module for lbdb
#     Copyright (C) 2000 Dave Pearson <davep@davep.org>
# 
#     This program is free software; you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation; either version 2 of the License, or
#     (at your option) any later version.
# 
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
# 
#     You should have received a copy of the GNU General Public License
#     along with this program; if not, write to the Free Software
#     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
#
# $Id: m_palm.sh.in,v 1.5 2002/02/11 19:23:53 roland Exp $

prefix=/usr
exec_prefix=/usr
libdir=/usr/lib/lbdb

m_palm_query ()
{
    palmdatabase=${PALM_ADDRESS_DATABASE:-$HOME/.jpilot/AddressDB.pdb}
    test -f $palmdatabase || return
    palmdatabase_charset=$(fgrep char_set $HOME/.jpilot/jpilot.rc | perl -e '($a = <>) =~ s/^\s*char_set\s*(\d+)\s*$/$1/; print $a == 0 ? "LATIN1" : $a == 1 ? "JAPANESE" : $a == 2 ? "1250" : $a == 3 ? "KOI8-R" : $a == 4 ? "CP1251" : $a == 5 ? "TRADITIONAL_CHINESE" : $a == 6 ? "KOREAN" : $a == 7 ? "1250UTF" : "UNKNOWN"')
    $libdir/palm_lsaddr $palmdatabase $palmdatabase_charset | grep -i "$@"
}
