commit 2d3ceb01fc91445639962960a688ce3e08353986
parent cb2002f7d05b97aea2cd0da71b3fb1e0a64c8bc7
Author: Jaromil <jaromil@dyne.org>
Date:   Mon, 19 Mar 2012 22:44:45 +0100
added little brother database
Diffstat:
39 files changed, 3645 insertions(+), 0 deletions(-)
diff --git a/share/lbdb/COPYING b/share/lbdb/COPYING
@@ -0,0 +1,340 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+	51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/share/lbdb/README b/share/lbdb/README
@@ -0,0 +1,212 @@
+$Id: README,v 1.37 2007-05-27 08:42:22 roland Exp $
+
+
+               The Little Brother's Database
+                
+          Roland Rosenfeld <roland@spinnaker.de> (current maintainer)
+            Thomas Roessler <roessler@guug.de> (initial author)
+
+This package was inspired by the Big Brother Database package
+available for various Emacs mailers, and by Brandon Long's "external
+query" patch for the mutt mail user agent (Note that this patch has
+been incorporated into the main-line mutt versions as of mutt 0.93.)
+
+The package doesn't use any formal database libraries or languages,
+although it should be quite easy to extend it to use, e.g., an
+installed PostgreSQL server as it's backend.
+
+For querying the Little Brother, just type "lbdbq <something>". lbdbq
+will now attempt to invoke various modules to gather information about
+persons matching "<something>". E.g., it may look at a list of
+addresses from which you have received mail, it may look at YP maps,
+or it may try to finger <something>@<various hosts>.
+
+The behavior is configurable: Upon startup, lbdbq will source the
+shell scripts
+
+        /usr/local/etc/lbdb.rc (or where your @sysconfdir@ points to)
+        $HOME/.lbdbrc
+        $HOME/.lbdb/lbdbrc
+        $HOME/.lbdb/rc
+
+if they exist.
+
+They can be used to set the following global variables:
+
+- MODULES_PATH: Where lbdbq should look for modules
+
+- METHODS: What modules to use.
+
+- SORT_OUTPUT: Set this to "false" or "no" and lbdbq won't sort the
+  addresses but returns them in reverse order (which means that the
+  most recent address in m_inmail database is first).  If you set this
+  to "name", lbdbq sorts the output by real name.  If you set this to
+  "comment", it sort the output by the comment (for example the date
+  in m_inmail). If you set this to "address", lbdbq sorts the output
+  by addresses (that's the default).
+
+
+Note that there _are_ defaults, so you should most probably modify
+these variables using constructs like this:
+
+        MODULES_PATH="MODULES_PATH $HOME/lbdb_modules"
+
+Additionally, modules may have configuration variables of their own.
+
+Currently the following modules are supplied with lbdb:
+
+m_finger
+       This module will use finger to find out something more about a
+       person. The list of hosts do be asked is configurable; use the
+       M_FINGER_HOSTS variable. Note that "localhost" will mean an
+       invocation of your local finger(1) binary, and should thus work
+       even if you don't provide the finger service to the network.
+       m_finger tries to find out the machines mail domain name in
+       /etc/mailname, by parsing a sendmail.cf file (if it finds one)
+       and by reading /etc/hostname and /etc/HOSTNAME.
+
+m_inmail
+       This module will look up user name fragments in a list of mail
+       addresses created by lbdb-fetchaddr(1).
+
+m_passwd
+       This module searches for matching entries in your local
+       /etc/passwd file. It evaluates the local machine mail domain in
+       the same way m_finger does.  If you set PASSWD_IGNORESYS=true,
+       this module ignores all system accounts and only finds UIDs
+       between 1000 and 29999 (all other UIDs are reserved on a Debian
+       system).
+
+m_yppasswd
+       This module searches for matching entries in your NIS password
+       file using the command "ypcat passwd".
+
+m_nispasswd
+       This module searches for matching entries in the NIS+ password
+       database using the command ``niscat passwd.org_dir''.
+
+m_getent
+       This module searches for matching entries in whatever password
+       database is configured using the command ``getent passwd''.
+
+m_pgp2, m_pgp5, m_gpg
+       These modules scan your PGP 2.*, PGP 5.* or GnuPG public key
+       ring for data. They use the programs pgp(1), pgpk(1), or gpg(1)
+       to get the data.
+
+m_fido 
+       This module searches your Fido nodelist, stored in
+       $HOME/.lbdb/nodelist created by nodelist2lbdb(1).
+
+m_abook
+       This module uses the program abook
+       (http://www.linuxstart.com/~jheinonen/abook/), a text based
+       address book application to search for addresses.  You can
+       define multiple abook address books by setting the variable
+       ABOOK_FILES to a space separated list.
+
+m_addr_email
+       This module uses addr-email from the addressbook
+       (http://red.roses.de/~clemens/addressbook/) Tk program to
+       search for addresses.
+
+m_muttalias
+       This module searches the variable MUTTALIAS_FILES (a space
+       separated list) of files in MUTT_DIRECTORY that contain mutt
+       aliases.  File names without leading slash will have
+       MUTT_DIRECTORY (defaults to $HOME/.mutt or $HOME, if
+       $HOME/.mutt does not exist) prepended before the file name.
+       Absolute file names (beginning with /) will be taken direct.
+
+m_pine
+       This  module searches pine(1) addressbook files for
+       aliases. To realize this it first inspects the variable PINERC.
+       If it isn't set, the default `/etc/pine.conf
+       /etc/pine.conf.fixed .pinerc' is used. To suppress inspecting
+       the PINERC variable, set it to "no". It than takes all
+       address-book and global-address-book entries from these pinerc
+       files and adds the contents of the variable PINE_ADDRESSBOOKS
+       to the list, which defaults to `/etc/addressbook .addressbook'.
+       Then these addressbooks are searched for aliases. All filenames
+       without leading slash are searched in $HOME.
+
+m_palm
+       This module searches the Palm address database using the
+       Palm::PDB and Palm::Address Perl modules from CPAN.  It
+       searches in the variable PALM_ADDRESS_DATABASE or if this isn't
+       set in $HOME/.jpilot/AddressDB.pdb.
+
+m_gnomecard
+       This module searches for addresses in your GnomeCard database
+       files.  The variable GNOMECARD_FILES is a whitespace separated
+       list of GnomeCard data files.  If this variable isn't defined,
+       the module searches in $HOME/.gnome/GnomeCard for the GnomeCard
+       database or at least falls back to $HOME/.gnome/GnomeCard.gcrd.
+       If a filename does not start with a slash, it is prefixed with
+       $HOME/.
+
+m_bbdb
+       This module searches for addresses in your (X)Emacs BBDB (big
+       brother database).  It doesn't access ~/.bbdb directly (yet)
+       but calls (x)emacs with a special mode to get the information
+       (so don't expect too much performance in this module). You can
+       configure the EMACS variable to tell this module which emacsen
+       to use.  Otherwise it will fall back to emacs or xemacs.
+
+m_ldap
+       This module queries an LDAP server using the Net::LDAP Perl
+       modules from CPAN.  It can be configured using an external
+       resource file (for more details please refer to the
+       mutt_ldap_query(1) manual page).
+
+m_wanderlust
+       This module searches for addresses stored in your
+       $WANDERLUST_ADDRESSES (or by default in $HOME/.addresses) file,
+       an addressbook of WanderLust.
+
+m_osx_addressbook
+       This module queries the OS X AddressBook.  It is only available
+       on OS X systems.
+
+m_evolution
+       This module queries the Ximian Evolution address book using the
+       evolution-addressbook-export application.
+
+m_vcf
+       This module uses libvformat to search for addresses from the
+       space-separated set of vCard files defined in $VCF_FILES.
+
+
+Feel free to create your own modules to query other kinds of
+databases.  m_finger should be a good example of how to do it.
+
+If you create your own modules or have other changes and feel that
+they could be helpful for others, don't hesitate to submit them to me
+for inclusion in later releases.
+
+Finally, to use lbdbq from mutt, add the following line to your
+~/.muttrc:
+
+        set query_command="lbdbq %s"
+
+
+CREDITS
+-------
+
+Most of the really interesting code of this program (namely, the RFC
+822 address parser used by lbdb-fetchaddr) was stolen from Michael
+Elkins' mutt mail user agent. Additional credits go to Brandon Long
+for putting the query functionality into mutt.
+
+Many thanks to the authors of the several modules and extensions:
+- Ross Campbell <rcampbel@us.oracle.com>           (m_abook, m_yppasswd)
+- Marc de Courville <marc@courville.org>           (m_ldap, mutt_ldap_query)
+- Brendan Cully <brendan@kublai.com>               (m_osx_addressbook, m_vcf)
+- Gabor Fleischer <flocsy@mtesz.hu>                (m_pine)
+- Rick Frankel <rick@rickster.com>                 (m_gnomecard)
+- Guido Guenther <agx@sigxcpu.org>                 (m_evolution)
+- Utz-Uwe Haus <haus@uuhaus.de>                    (m_bbdb, m_nispasswd)
+- Torsten Jerzembeck <toje@nightingale.ms.sub.org> (m_addr_email)
+- Gergely Nagy <algernon@debian.org>               (m_wanderlust)
+- Dave Pearson <davep@davep.org>                   (m_palm, lbdb.el)
+- Brian Salter-Duke <b_duke@bigpond.net.au>        (m_muttalias)
diff --git a/share/lbdb/lbdb-fetchaddr.man.in b/share/lbdb/lbdb-fetchaddr.man.in
@@ -0,0 +1,122 @@
+.\" -*- nroff -*-
+.\" Copyright (c) 1998-2005  Roland Rosenfeld <roland@spinnaker.de>
+.\"               
+.\" 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+.\"
+.TH LBDB-FETCHADDR 1 "October 2005" "Unix" "User Manuals"
+.SH NAME
+lbdb-fetchaddr \- grab addresses from mails add append them to lbdb database
+.SH SYNOPSIS
+.B lbdb-fetchaddr
+.RB [ -d 
+.IR dateformat ]
+.RB [ -x
+.IR headerfieldlist ]
+.RB [ -c
+.IR charset ]
+.RB [ -a ]
+.br
+.B lbdb-fetchaddr
+.RB [ -v | -h ]
+.SH DESCRIPTION
+.B lbdb-fetchaddr
+is a shell script which reads a mail on stdin. It extracts the
+contents of some header fields (default:
+.RB ` From: ', 
+.RB ` To: ', 
+.RB ` Cc: ', 
+.RB ` Resent-From: ', 
+and
+.RB ` Resent-To: ')
+from the mail header (only addresses with a real name) and appends
+them to 
+.IR $HOME/.lbdb/m_inmail.list .
+For performance issues 
+.B lbdb-fetchaddr
+appends new addresses to this file without removing duplicates. To get
+rid of duplicates, the program
+.B lbdb-munge
+exists, which is run by
+.B m_inmail
+if needed and removes duplicates.
+.PP
+To use this program, put the following lines into your 
+.I $HOME/.procmailrc:
+.nf  
+     :0hc
+     | lbdb-fetchaddr
+.fi 
+.PP
+.B lbdb-fetchaddr
+writes the actual date to the third column of the database by using
+.BR strftime (3).
+It uses "%Y-%m-%d %H:%M" as the default date format (e.g. "1999-04-29
+14:33"). You can change this by using the 
+.B -d
+option to select a different date format string as parameter of
+lbdb-fetchaddr command like
+.nf  
+     :0hc
+     | lbdb-fetchaddr \-d "%y-%m-%d"
+.fi
+which results in e.g. "99-04-29".
+.SH OPTIONS
+.TP
+.B -v
+Print version number of lbdb-fetchaddr.
+.TP
+.B -h
+Print short help of lbdb-fetchaddr.
+.TP
+.BI -d " dateformat"
+Use the given date format using 
+.BR strftime (3)
+syntax.
+.TP
+.BI -x " headerfields"
+A colon separated list of header fields, which should be searched for
+mail addresses.  If this option isn't given, we fall back to
+.RB ` from:to:cc:resent-from:resent-to '.
+.TP
+.BI -c " charset"
+The charset which will be used to write the database. This should be
+the charset which the application expects (normally the one from your
+current locale).  If this option isn't given, we fall back to
+.RB ` iso-8859-15 '.
+.TP
+.B -a
+Also grab addresses without a real name.  Use the local part of the
+mail address as real name.
+.SH FILES
+.I $HOME/.lbdb/m_inmail.list
+.br
+.I @libdir@/fetchaddr
+.br
+.I @libdir@/m_inmail
+.SH "SEE ALSO"
+.BR lbdbq (1),
+.BR @dotlock@ (1),
+.BR procmail (1),
+.BR procmailrc (5),
+.BR strftime (3).
+.SH CREDITS
+Most of the really interesting code of this program (namely, the RFC
+822 address parser used by lbdb-fetchaddr) was stolen from Michael
+Elkins' mutt mail user agent. Additional credits go to Brandon Long
+for putting the query functionality into mutt.
+.SH AUTHOR
+The lbdb package was written by Thomas Roessler <roessler@guug.de> and
+is now maintained and extended by Roland Rosenfeld
+<roland@spinnaker.de>.
diff --git a/share/lbdb/lbdb-fetchaddr.sh.in b/share/lbdb/lbdb-fetchaddr.sh.in
@@ -0,0 +1,127 @@
+#! @SH@
+#
+# -*-sh-*-
+#     Copyright (C) 1998-2000  Thomas Roessler <roessler@guug.de>
+#                   1999-2005  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: lbdb-fetchaddr.sh.in,v 1.20 2007-10-28 16:33:36 roland Exp $
+
+LBDB_VERSION=@LBDB_VERSION@
+
+umask 077
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+dotlock=@DOTLOCK@
+fetchaddr=@libdir@/fetchaddr
+db=$HOME/.lbdb/m_inmail.list
+
+datefmt='%Y-%m-%d %H:%M'
+additional_param=""
+
+usage() {
+    echo "Usage: $0 [OPTIONS]"
+    echo "       dig addresses from stdin with formatted timestamp"
+    echo "Options:"
+    echo "       -v                 print version of lbdbq"
+    echo "       -h                 this short help"
+    echo "       -d 'dateformat'    select date format using strftime(3)"
+    echo "       -x 'from:to:cc'    colon separated list of header fields"
+    echo "       -c 'charset'       charset for the database storage"
+    echo "       -a                 also grep addresses without realname"
+}
+
+while [ $# -gt 0 ]
+do
+    case "$1" in
+    -v) 
+	echo "lbdb-fetchaddr version $LBDB_VERSION"
+	exit 0
+	;;
+    -h) 
+	usage
+	exit 0
+	;;
+    -d)
+	if [ $# -gt 1 ]
+	then
+	    shift
+	    datefmt="$1"
+	fi
+	;;
+    -x)
+	if [ $# -gt 1 ]
+	then
+	    shift
+	    hdrlist="-x $1"
+	fi
+	;;
+    -c)
+	if [ $# -gt 1 ]
+	then
+	    shift
+	    charset="-c $1"
+	fi
+	;;
+    -a)
+	additional_param="$additional_param $1"
+	;;
+    *)
+	if [ $# -eq 1 ]
+	then
+	    # backward compatibility:
+	    # only one parameter means, that this is the selected datefmt
+	    datefmt="$1"
+	else
+	    echo "Wrong number of parameters!"
+	    usage
+	    exit 1
+	fi
+	;;
+    esac
+    shift
+done
+
+if [ ! -f $db ]; then
+  dbdir=`dirname $db`
+  if [ ! -d $dbdir ]; then
+    mkdir -p $dbdir
+    if [ ! -d $dbdir ]; then
+      echo "Can't create $dbdir" >&2
+      exit 1
+    fi
+  fi
+  touch $db
+  if [ ! -f $db ]; then
+    echo "Can't create $db" >&2
+    exit 1
+  fi
+fi
+
+if $dotlock -r 10 -f $db
+then
+  : # okay, do nothing
+else
+  echo "Can't lock $db [dotlock returned $rv]." >&2
+  exit 1
+fi
+
+if $fetchaddr $additional_param -d "$datefmt" $hdrlist $charset >> $db ; then
+  touch $db.dirty
+fi
+
+$dotlock -u $db
diff --git a/share/lbdb/lbdb-munge.sh.in b/share/lbdb/lbdb-munge.sh.in
@@ -0,0 +1,63 @@
+#! @SH@
+#
+# -*-sh-*-
+#
+#     Copyright (C) 1999-2005  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: lbdb-munge.sh.in,v 1.8 2005-10-29 14:48:09 roland Exp $
+
+LBDB_VERSION=@LBDB_VERSION@
+
+umask 077
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+dotlock=@DOTLOCK@
+fetchaddr=@libdir@/fetchaddr
+db=$HOME/.lbdb/m_inmail.list
+
+if [ "$SORT_OUTPUT" = "false" -o "$SORT_OUTPUT" = "no" ]
+then
+    munge=@libdir@/munge-keeporder
+else
+    munge=@libdir@/munge
+fi
+
+if [ ! -f $db.dirty ]; then
+    # Nothing to do
+    exit 0
+fi
+
+if $dotlock -r 10 -f $db
+then
+  : # okay, do nothing
+else
+  echo "Can't lock $db [dotlock returned $rv]." >&2
+  exit 1
+fi
+
+if $munge < $db > $db.$$.tmp 2>/dev/null
+then
+    # only move, if munge successful:
+    mv -f $db.$$.tmp $db
+    rm -f $db.dirty
+else
+    rm -f $db.$$.tmp
+    # maybe write a debug log here...
+fi
+
+$dotlock -u $db
diff --git a/share/lbdb/lbdb.rc.in b/share/lbdb/lbdb.rc.in
@@ -0,0 +1,190 @@
+#
+# This is the main configuration file of the little brothers database lbdb
+#
+# Everything you configure here can be overridden by the users config
+# file which can be found at
+# ~/.lbdbrc
+# ~/.lbdb/lbdbrc
+# ~/.lbdb/rc
+# (evaluated with ascending priority!)
+# 
+# (c) 1999-2006 Roland Rosenfeld <roland@spinnaker.de>
+#
+# $Id: lbdb.rc.in,v 1.18 2006-10-14 12:10:42 roland Exp $
+#
+
+#
+# Select which methods you want to use in which order (ascending priority):
+# (a space separated list)
+#
+# - m_inmail	 search the database created by lbdb-fetchaddr(1)
+# - m_finger	 finger some hosts defined in variable M_FINGER_HOSTS
+# - m_passwd	 search the local /etc/passwd file.
+# - m_yppasswd	 search the NIS password database.
+# - m_nispasswd	 search the NIS+ password database.
+# - m_getent	 search the password database (whatever is configured).
+# - m_pgp2	 search your PGP 2.* keyring
+# - m_pgp5	 search your PGP 5.* keyring
+# - m_gpg	 search your GnuPG keyring
+# - m_fido	 search the Fido nodelist converted by nodelist2lbdb(1)
+# - m_abook	 query abook(1), the text based address book application.
+# - m_addr_email query addr-email(1) from addressbook Tk-program.
+# - m_muttalias  search $MUTTALIAS_FILES for aliases.
+# - m_pine	 search pine(1) addressbook files for aliases.
+# - m_palm	 search your Palm addressbook file.
+# - m_gnomecard	 search your GnomeCard address database files.
+# - m_bbdb	 search your BBDB (big brother database).
+# - m_ldap       query an LDAP server 
+# - m_wanderlust search your wanderlust ~/.addresses file.
+# - m_osx_addressbook  search the OS X addressbook (only available on OS X).
+# - m_evolution  search in the Ximan Evolution addressbook.
+# - m_vcf        search a vcard (according to RFC2426) file.
+
+METHODS="m_inmail m_passwd m_finger"
+
+
+#
+# If you want m_finger to ask other host then localhost, create a list here:
+# (a space separated list):
+#
+#M_FINGER_HOSTS="master.debian.org va.debian.org localhost"
+
+#
+# If it isn't possible to find out the correct mail domain name of
+# your system in /etc/mailname, by reading sendmail.cf, /etc/hostname
+# or /etc/HOSTNAME, you can specify it in the variable
+# MAIL_DOMAIN_NAME. This overrides all other mechanisms.
+#
+#MAIL_DOMAIN_NAME=does-not-exist.org
+
+# - m_muttalias      query set of mutt alias files:
+#
+# Set MUTTALIAS_FILES below to list of files in MUTT_DIRECTORY that
+# contain mutt aliases. File names without leading slash will have
+# $MUTT_DIRECTORY (defaults to $HOME/.mutt or $HOME, if ~/.mutt does
+# not exist) prepended before the file name. Absolute file names
+# (beginning with /) will be taken direct.
+#
+#MUTT_DIRECTORY="$HOME/.mutt"
+#MUTTALIAS_FILES=".muttrc .mail_aliases muttrc aliases"
+
+
+# - m_pine	search pine addressbook files for aliases:
+#
+# This module first inspects the variable PINERC. If it isn't set, the
+# default `/etc/pine.conf /etc/pine.conf.fixed .pinerc' is used. To
+# suppress inspecting the PINERC variable, set it to "no". It than
+# takes all address-book and global-address-book entries from these
+# pinerc files and adds the contents of the variable PINE_ADDRESSBOOKS
+# to the list, which defaults to `/etc/addressbook .addressbook'. Then
+# these addressbooks are searched for aliases. All filenames without
+# leading slash are searched in $HOME.
+#
+#PINERC="/etc/pine.conf /etc/pine.conf.fixed .pinerc"
+#PINE_ADDRESSBOOKS="/etc/addressbook .addressbook"
+
+
+# - m_wanderlust      search your WanderLust addresses files:
+#
+# Set WANDERLUST_ADDRESSES below to point to your WanderLust address
+# book.  If you don't set this variable, the default
+# ($HOME/.addresses) is used.
+#
+#WANDERLUST_ADDRESSES="$HOME/.addresses"
+
+
+# - m_palm	search your Palm addressbook file:
+#
+# This module searches the Palm address database using the Palm::PDB
+# and Palm::Address Perl modules from CPAN. It searches in the
+# variable PALM_ADDRESS_DATABASE or if this isn't set in
+# $HOME/.jpilot/AddressDB.pdb.
+#
+#PALM_ADDRESS_DATABASE="$HOME/.jpilot/AddressDB.pdb"
+
+
+# - m_gnomecard	 search your GnomeCard address database files.
+#
+# This module searches for addresses in your GnomeCard database files.
+# The variable GNOMECARD_FILES is a whitespace separated list of
+# GnomeCard data files. If this variable isn't defined, the module
+# searches in $HOME/.gnome/GnomeCard for the GnomeCard database or at
+# least falls back to $HOME/.gnome/GnomeCard.gcrd. If a filename does
+# not start with a slash, it is prefixed with $HOME/.
+#
+#GNOMECARD_FILES="$HOME/.gnome/GnomeCard.gcrd"
+
+
+# - m_bbdb  search your BBDB (big brother database).
+#
+# This module searches for addresses in your (X)Emacs BBDB (big
+# brother database). It doesn't access ~/.bbdb directly (yet) but
+# calls emacs(1) or xemacs(1) with a special mode to get the
+# information (so don't expect too much performance in this module).
+# You can configure the EMACS variable to tell this module which
+# emacsen to use. Otherwise it will fall back to emacs or xemacs.
+#
+#EMACS="emacs"
+
+
+# - m_ldap  query an LDAP server.
+#
+# This module queries an LDAP server using the Net::LDAP Perl modules
+# from CPAN. It can be configured using an external resource file. You
+# can explicity define a LDAP query in this file or you can use one or
+# more of the predefined queries from the %ldap_server_db in this
+# file. For this you have to define the selected enties as a space
+# separated list in the the variable LDAP_NICKS.
+#
+#LDAP_NICKS="debian bigfoot"
+
+
+# - m_abook query the abook(1) programm
+#
+# if you have more than one abook addressbook, use the ABOOK_FILES
+# variable. It contains a space separated list of all your files. 
+# Default is $HOME/.abook/addressbook $HOME/.abook.addressbook
+# ABOOK_FILES="$HOME/.abook/friends $HOME/.abook/work"
+
+
+# - m_passwd search in /etc/passwd
+#
+# On a Debian system only the UIDs 1000-29999 are used for normal
+# users.  Setting PASSWD_IGNORESYS to "true" implies that lbdbq
+# ignores and UID, which isn't in that range:
+#PASSWD_IGNORESYS=true
+
+
+# - m_vcf search in vcard files
+#
+# You have to define the vcard files space separated in $VCF_FILES to
+# make this module work:
+#VCF_FILES=$HOME/my.vcf
+
+
+#
+# If you want to use private modules set the MODULES_PATH to find them:
+# (a space separated list):
+#
+#MODULES_PATH="/usr/lib/lbdb $HOME/.lbdb/modules"
+
+
+#
+# Do you want the output to be sorted?
+# If you set this to "false" or "no", lbdbq won't sort the addresses
+# but returns them in reverse order (which means that the most recent
+# address in m_inmail database is first).
+# If you set this to "name", lbdbq sorts the output by real name.
+# If you set this to "comment", lbdbq sorts the output by comment (column 3).
+# If you set this to "reverse_comment", lbdbq sorts the output by comment 
+#                                       but with reverse order (column 3).
+# If you set this to "address", lbdbq sorts the output by addresses
+# (that's the default).
+#
+#SORT_OUTPUT=address
+
+#
+# Do you want to see duplicate mail addresses (with multiple real
+# names or different comment fields)?  Default is "no".
+#
+#KEEP_DUPES=no
diff --git a/share/lbdb/lbdb.spec.in b/share/lbdb/lbdb.spec.in
@@ -0,0 +1,79 @@
+%define ver      @LBDB_VERSION@
+%define rel      2
+%define prefix   /usr
+
+Summary: The Little Brother's Database
+Name: lbdb
+Version: %ver
+Release: %rel
+Copyright: GNU General Public Licence
+URL: http://www.spinnaker.de/lbdb/
+Packager: Horms <horms@vergenet.net>
+Vendor: Horms
+Group: Applications/Databases
+Source: http://www.spinnaker.de/debian/lbdb_%{ver}.tar.gz
+NoSource: 0
+BuildRoot: /var/tmp/lbdb-%{PACKAGE_VERSION}-root
+Docdir: %{prefix}/doc
+
+%description
+This package was inspired by the Big Brother Database package available for
+various Emacs mailers, and by Brandon Long's "external query" patch for the
+Mutt mail user agent. (Note that this patch has been incorporated into the
+main-line mutt versions as of mutt 0.93.)
+
+The package doesn't use any formal database libraries or languages,
+although it should be quite easy to extend it to use, e.g., an installed
+PostgreSQL server as it's back end.
+
+%prep
+%setup -q
+
+%build
+%configure 2>&1 | tee -a Configurings-`date +%Y.%m.%d`
+
+#Funky NPROC code to speed things up courtesy of Red Hat's kernel rpm
+if [ -x /usr/bin/getconf ] ; then
+    NRPROC=$(/usr/bin/getconf _NPROCESSORS_ONLN)
+    if [ $NRPROC -eq 0 ] ; then
+        NRPROC=1
+    fi
+else
+    NRPROC=1
+fi
+NRPROC=`expr $NRPROC + $NRPROC`
+
+make -j $NRPROC  2>&1 | tee -a Makings-`date +%Y.%m.%d`
+
+%install
+rm -rf $RPM_BUILD_ROOT
+mkdir -p ${RPM_BUILD_ROOT}/%{prefix}/etc
+
+make install_prefix=${RPM_BUILD_ROOT} install 2>&1 \
+    | tee -a Makings-Install-`date +%Y.%m.%d`
+
+%clean
+rm -rf ${RPM_BUILD_DIR}/lbdb-%{ver}
+rm -rf ${RPM_BUILD_ROOT}
+
+%files
+%defattr(-,root,root)
+%doc README COPYING
+# Keep copies of the configure, build, install reports in the
+# documentation of the package.
+%doc Makings-Install-`date +%Y.%m.%d`
+%doc Makings-`date +%Y.%m.%d`
+%doc Configurings-`date +%Y.%m.%d`
+%{prefix}
+
+%changelog
+* Sat Dec 30 2000 Rob Payne <rnspayne@adelphia.net>
+- Changed to fit version 0.22
+- Change installation process to include RPM_BUILD_ROOT
+- Removed auto-generated files list that did not take into account RPM
+  4's automatic compression of the man pages *after* the
+  auto-generation was running.
+- Removed the empty post, postun, preun scripts.
+
+* Mon Apr 10 2000 Horms <horms@vergenet.net>
+- created for version 0.18.5
diff --git a/share/lbdb/lbdb_lib.sh.in b/share/lbdb/lbdb_lib.sh.in
@@ -0,0 +1,80 @@
+#! @SH@
+#
+# -*-sh-mode-*-
+#
+#     Copyright (C) 1998  Thomas Roessler <roessler@guug.de>
+#     Copyright (C) 1999-2006  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: lbdb_lib.sh.in,v 1.7 2006-08-13 08:53:21 roland Exp $
+
+
+#
+# library routines
+#
+
+lbdb_hn_sendmail()
+{
+	sendmail_cf="NONE"
+	for p in /etc /etc/mail /etc/sendmail ; do
+		if test -r $p/sendmail.cf ; then
+			sendmail_cf=$p/sendmail.cf
+		 	break;
+		fi
+	done
+	
+	if test "x$sendmail_cf" != "xNONE" ; then
+		hn="`sed -n -e 's/^DM\(.*\)$/\1/p' $sendmail_cf`"
+		if test "x$hn" = x ; then
+			hn="`sed -n -e 's/^Dj\(.*\)$/\1/p' $sendmail_cf`"
+		fi
+	fi
+	if test "x$hn" = x ; then
+		echo "NONE"
+	else
+		echo "$hn"
+	fi
+}
+
+
+lbdb_hostname()
+{
+	if test "x$MAIL_DOMAIN_NAME" != "x" ; then
+		hn=$MAIL_DOMAIN_NAME
+	elif test -f /etc/mailname; then
+		hn=`cat /etc/mailname`
+	else
+		hn=""
+		if test -r /etc/resolv.conf ; then
+			hn="`sed -n -e 's/^[ 	]*domain[ 	]\{1,\}\([^ ]*\)/\1/p' /etc/resolv.conf`"
+			if test "x$hn" = "x" ; then
+				hn="`sed -n -e 's/^[ 	]*search[ 	]\{1,\}\([^ ]*\)/\1/p' /etc/resolv.conf`"
+			fi
+		fi
+		if test "x$hn" = "x" ; then
+			hn=`lbdb_hn_sendmail`
+			if test "x$hn" = "xNONE" ; then
+				for i in /etc/HOSTNAME /etc/hostname ; do
+					if test -f $i ; then
+						hn="`cat $i`"
+						break;
+					fi
+				done
+			fi
+		fi
+	fi
+	echo "$hn"
+}
diff --git a/share/lbdb/lbdbq.man.in b/share/lbdb/lbdbq.man.in
@@ -0,0 +1,378 @@
+.\" -*- nroff -*-
+.\" Copyright (c) 1998-2007  Roland Rosenfeld <roland@spinnaker.de>
+.\"               
+.\" 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+.\"
+.\" $Id: lbdbq.man.in,v 1.49 2010-05-18 17:51:02 roland Exp $
+.\"
+.TH LBDBQ 1 "September 2007" "Unix" "User Manuals"
+.SH NAME
+lbdbq \- query program for the little brother's database
+.SH SYNOPSIS
+.B lbdbq
+.I something
+.br
+.B lbdbq
+.RB [ -v | --version | -h | --help ]
+.SH DESCRIPTION
+.B lbdbq
+is the client program for the little brother's database. It will
+attempt to invoke various modules to gather information about persons
+matching
+.IR something .
+E.g., it may look at a list of addresses from which you have received
+mail, it may look at YP maps, or it may try to finger
+.IR something @ "<various hosts>" .
+.PP
+The behavior is configurable: Upon startup, 
+.B lbdbq
+will source the shell scripts:
+.RS
+.I @sysconfdir@/lbdb.rc
+.br
+.I $HOME/.lbdbrc
+.br
+.I $HOME/.lbdb/lbdbrc
+.br
+.I $HOME/.lbdb/rc
+.RE
+if they exist.
+.PP
+They can be used to set the following global variables:
+.TP
+.B MODULES_PATH
+a space separated list of directories, where 
+.B lbdbq
+should look for modules.
+.TP
+.B METHODS
+a space separated list of the modules to use.
+.TP
+.B SORT_OUTPUT
+If you set this to 
+.I false
+or 
+.IR no ,
+lbdbq won't sort the addresses but returns them in reverse order
+(which means that the most recent address in m_inmail database is
+first). If you set this to 
+.IR name ,
+lbdbq sorts the output by real name.  If you set this to 
+.IR comment ,
+it sort the output by the comment (for example the date in 
+.BR m_inmail ).
+.I reverse_comment
+realizes the same as 
+.IR comment ,
+but in reverse order, so the most recent timestamp of m_inmail may be
+on top. If you set SORT_OUTPUT to
+.IR address ,
+lbdbq sorts the output by addresses (that's the default).
+.TP
+.B KEEP_DUPES
+If you set this to
+.I true
+or
+.IR yes ,
+lbdbq won't remove duplicate addresses with different real name
+comment fields.
+.PP
+Note that there 
+.I are
+defaults, so you should most
+probably modify these variables using constructs like this:
+.nf
+       MODULES_PATH="$MODULES_PATH $HOME/lbdb_modules"
+.fi
+.PP
+Additionally, modules may have configuration variables of
+their own.
+.SH MODULES
+Currently, the following modules are supplied with lbdb:
+.TP
+.B m_finger
+This module will use finger to find out something more about a person.
+The list of hosts do be asked is configurable; use the 
+.B M_FINGER_HOSTS
+variable. Note that "localhost" will mean an invocation of your local
+.BR finger (1)
+binary, and should thus work even if you don't provide the finger
+service to the network.
+.B m_finger
+tries to find out the machines mail domain name in
+.IR /etc/mailname ,
+by parsing a
+.I sendmail.cf
+file (if it finds one) and by reading
+.I /etc/hostname
+and
+.IR /etc/HOSTNAME .
+If you know that this fails on your machine, or you want to force lbdbq
+to consider some other name to be the local mail domain name (misconfigured
+SUNs come to mind here), you can specify a name using the
+.B MAIL_DOMAIN_NAME
+variable. If this variable is set by you, no probing will be done by
+.BR lbdbq .
+.TP
+.B m_inmail
+This module will look up user name fragments in a list of mail
+addresses created by
+.BR lbdb-fetchaddr (1).
+.TP
+.B m_passwd
+This module searches for matching entries in your local /etc/passwd
+file. It evaluates the local machine mail domain in the same way 
+.B m_finger
+does.  If you set
+.BR PASSWD_IGNORESYS=true ,
+this module ignores all system accounts and only finds UIDs between
+1000 and 29999 (all other UIDs are reserved on a Debian system).
+.TP
+.B m_yppasswd
+This module searches for matching entries in the NIS password database
+using the command ``ypcat passwd''.
+.TP
+.B m_nispasswd
+This module searches for matching entries in the NIS+ password database
+using the command ``niscat passwd.org_dir''.
+.TP
+.B m_getent
+This module searches for matching entries in whatever password
+database is configured using the command ``getent passwd''.
+.TP
+.BR m_pgp2 ", " m_pgp5 ", " m_gpg
+These modules scan your PGP 2.*, PGP 5.* or GnuPG public key ring for
+data. They use the programs
+.BR pgp (1),
+.BR pgpk (1),
+or
+.BR gpg (1)
+to get the data.
+.TP
+.BR m_fido
+This module searches your Fido nodelist, stored in
+.I $HOME/.lbdb/nodelist
+created by
+.BR nodelist2lbdb (1).
+.TP
+.BR m_abook
+This module uses the program
+.BR abook (1),
+a text based address book application to search for addresses.  You
+can define multiple abook address books by setting the variable
+.B ABOOK_FILES
+to a space separated list.
+.TP
+.BR m_addr_email
+This module uses the program
+.BR addr-email (1),
+a text based frontend to the Tk 
+.BR addressbook (1)
+application.
+.TP
+.BR m_muttalias
+This module searches the variable
+.B MUTTALIAS_FILES
+(a space separated list) of files in 
+.B MUTT_DIRECTORY
+that contain mutt aliases.  File names without leading slash will have
+.B MUTT_DIRECTORY
+(defaults to 
+.BI $HOME /.mutt
+or
+.BR $HOME ,
+if
+.BI $HOME /.mutt
+does not exist) prepended before the file name.  Absolute file names
+(beginning with 
+.IR / )
+will be taken direct.
+.TP
+.BR m_pine
+This module searches
+.BR pine (1)
+addressbook files for aliases.  To realize this it first inspects the
+variable
+.BR PINERC .
+If it isn't set, the default 
+.RI ` "/etc/pine.conf /etc/pine.conf.fixed .pinerc" '
+is used.  To suppress inspecting the
+.B PINERC
+variable, set it to
+.IR no .
+It than takes all 
+.B address-book
+and
+.B global-address-book
+entries from these pinerc files and adds the contents of the variable
+.B PINE_ADDRESSBOOKS
+to the list, which defaults to
+.RI ` "/etc/addressbook .addressbook" '.
+Then these addressbooks are searched for aliases.  All filenames
+without leading slash are searched in
+.BR $HOME .
+.TP
+.BR m_palm
+This module searches the Palm address database using the 
+.BR Palm::PDB (3pm)
+and
+.BR Palm::Address (3pm)
+Perl modules from CPAN.
+It searches in the variable
+.B PALM_ADDRESS_DATABASE
+or if this isn't set in 
+.IR $HOME/.jpilot/AddressDB.pdb .
+.TP
+.BR m_gnomecard
+This module searches for addresses in your GnomeCard database files.
+The variable 
+.B GNOMECARD_FILES
+is a whitespace separated list of GnomeCard data files.  If this
+variable isn't defined, the module searches in
+.BI $HOME /.gnome/GnomeCard
+for the GnomeCard database or at least falls back to
+.BI $HOME /.gnome/GnomeCard.gcrd\fR.
+If a filename does not start with a slash, it is prefixed with
+.BR $HOME/ .
+.TP
+.BR m_bbdb
+This module searches for addresses in your (X)Emacs BBDB (big brother
+database).  It doesn't access ~/.bbdb directly (yet) but calls
+.BR emacs (1)
+or
+.BR xemacs (1)
+with a special mode to get the information (so don't expect too much
+performance in this module).  You can configure the
+.B EMACS
+variable to tell this module which emacsen to use.  Otherwise it will
+fall back to 
+.B emacs
+or
+.BR xemacs.
+.TP
+.BR m_ldap
+This module queries an LDAP server using the 
+.BR Net::LDAP (3pm)
+Perl modules from CPAN.  It can be configured using an external
+resource file 
+.I @sysconfdir@/lbdb_ldap.rc
+You can explicity define a LDAP query in this file or you can use one
+or more of the predefined queries from the 
+.B %ldap_server_db
+in this file.  For this you have to define a space separated list of
+nicknames from entries in the variable
+.BR LDAP_NICKS .
+.TP
+.BR m_wanderlust
+This module searches for addresses stored in your
+.I $WANDERLUST_ADDRESSES 
+(or by default in 
+.IR $HOME/.addresses )
+file, an addressbook of
+.BR WanderLust .
+.TP
+.BR m_osx_addressbook
+This module queries the OS X AddressBook.  It is only available on OS
+X systems.
+.TP
+.BR m_evolution
+This module queries the Ximian Evolution address book.  It depends on
+the program
+.BR evolution-addressbook-export ,
+which is shipped with evolution.
+.TP
+.BR m_vcf
+This module uses libvformat to search for addresses from the
+space\-separated set of vCard files defined in
+.IR $VCF_FILES .
+.PP
+Feel free to create your own modules to query other database resources,
+YP maps, and the like.
+.B m_finger
+should be a good example of how to do it.
+.PP
+If you create your own modules or have other changes and feel that
+they could be helpful for others, don't hesitate to submit them to the 
+author for inclusion in later releases.
+.PP
+Finally, to use
+.B lbdbq
+from mutt, add the following line to your
+.I $HOME/.muttrc:
+.nf
+    set query_command="lbdbq %s"
+.fi
+.SH OPTIONS
+.IP "-v | --version"
+Print version number of lbdbq.
+.IP "-h | --help"
+Print short help of lbdbq.
+.SH FILES
+.I @sysconfdir@/lbdb.rc
+.br
+.I $HOME/.lbdbrc
+.br
+.I $HOME/.lbdb/lbdbrc
+.br
+.I $HOME/.lbdb/rc
+.br
+.I @libdir@/*
+.br
+.I $HOME/.lbdb/m_inmail.list
+.br
+.I $HOME/.lbdb/nodelist
+.SH "SEE ALSO"
+.BR finger (1),
+.BR ypcat (1),
+.BR niscat (1),
+.BR getent (1),
+.BR pgp (1),
+.BR pgpk (1),
+.BR gpg (1),
+.BR lbdb-fetchaddr (1),
+.BR nodelist2lbdb (1),
+.BR mutt_ldap_query (1),
+.BR abook (1),
+.BR addr-email (1),
+.BR addressbook (1),
+.BR mutt (1),
+.BR pine (1),
+.BR emacs (1),
+.BR xemacs (1),
+.BR Palm::PDB (3pm),
+.BR Palm::Address (3pm),
+.BR Net::LDAP (3pm).
+.SH CREDITS
+Most of the really interesting code of this program (namely, the RFC
+822 address parser used by lbdb-fetchaddr) was stolen from Michael
+Elkins' mutt mail user agent. Additional credits go to Brandon Long
+for putting the query functionality into mutt.
+.PP
+Many thanks to the authors of the several modules and extensions:
+Ross Campbell <rcampbel@us.oracle.com> (m_abook, m_yppasswd),
+Marc de Courville <marc@courville.org> (m_ldap, mutt_ldap_query),
+Brendan Cully <brendan@kublai.com> (m_osx_addressbook, m_vcf),
+Gabor Fleischer <flocsy@mtesz.hu> (m_pine),
+Rick Frankel <rick@rickster.com> (m_gnomecard),
+Utz-Uwe Haus <haus@uuhaus.de> (m_bbdb, m_nispasswd),
+Torsten Jerzembeck <toje@nightingale.ms.sub.org> (m_addr_email),
+Adrian Likins <alikins@redhat.com> (m_getent),
+Gergely Nagy <algernon@debian.org> (m_wanderlust),
+Dave Pearson <davep@davep.org> (m_palm, lbdb.el), and
+Brian Salter-Duke <b_duke@bigpond.net.au> (m_muttalias).
+.SH AUTHOR
+The lbdb package was initially written by Thomas Roessler
+<roessler@guug.de> and is now maintained and heavily extended by
+Roland Rosenfeld <roland@spinnaker.de>.
diff --git a/share/lbdb/lbdbq.sh.in b/share/lbdb/lbdbq.sh.in
@@ -0,0 +1,116 @@
+#! @SH@
+#
+#     Copyright (C) 1998-2000  Thomas Roessler <roessler@guug.de>
+#                   1998-2007  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: lbdbq.sh.in,v 1.27 2007-05-20 13:00:44 roland Exp $
+
+LBDB_VERSION=@LBDB_VERSION@
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+sysconfdir=@sysconfdir@
+
+METHODS="@MODULES@"
+MODULES_PATH=@libdir@
+TAC=@TAC@
+
+case "$1" in
+    -v|--version)
+	echo "lbdbq version $LBDB_VERSION"
+	exit 0
+	break;;
+    -h|--help)
+	PROG=`basename $0`
+	echo "Usage: $PROG 'something'   search addresses matching 'something'"
+	echo "       $PROG -v|--version  print version of lbdbq"
+	echo "       $PROG -h|--help     this short help"
+	exit 0
+	break;;
+esac
+
+. $libdir/lbdb_lib
+
+tmpdir=${TMPDIR-/tmp}/query.`hostname`.$$
+mkdir $tmpdir || exit 1
+trap "rm -rf $tmpdir ; trap '' 0; exit 1" 0 1 2 3 15
+trap "rm -rf $tmpdir ; trap '' 0" 0
+collection=$tmpdir/coll
+
+for conffile in $sysconfdir/lbdb.rc $HOME/.lbdbrc \
+	$HOME/.lbdb/lbdbrc $HOME/.lbdb/rc ; do
+	
+  if test -f $conffile ; then
+    . $conffile
+  fi
+
+done
+
+for method in $METHODS ; do
+  for CURRENT_MODULE_DIR in $MODULES_PATH ; do
+    if test -f $CURRENT_MODULE_DIR/$method ; then
+      . $CURRENT_MODULE_DIR/$method
+      break
+    fi
+  done
+done
+
+for method in $METHODS ; do
+  eval ${method}_query \""$@"\" >> $collection || true
+done
+
+case "${KEEP_DUPES:-}" in
+    true|yes)
+	MUNGE=cat
+	MUNGE_KEEPORDER=cat
+	;;
+    *)
+	MUNGE=$libdir/munge
+	MUNGE_KEEPORDER=$libdir/munge-keeporder
+	;;
+esac
+
+case "${SORT_OUTPUT:-}" in
+    false|no)
+	$MUNGE_KEEPORDER $collection | $TAC > $collection.uniq
+	;;
+    *name)
+	$MUNGE $collection | sort -f -k2 > $collection.uniq
+	;;
+    reverse_comment)
+        $MUNGE $collection | sort -f -k3 -t'	' -r > $collection.uniq
+	;;
+    comment)
+        $MUNGE $collection | sort -f -k3 -t'	' > $collection.uniq
+	;;
+    *)
+	$MUNGE $collection | sort -f > $collection.uniq
+	;;
+esac
+
+lines=`wc -l $collection.uniq | awk '{print $1}'`
+
+if [ $lines = "0" ]
+then
+    echo "lbdbq: no matches"
+    exit 1
+else
+    echo "lbdbq: $lines matches"
+fi
+
+cat $collection.uniq
diff --git a/share/lbdb/m_abook.sh.in b/share/lbdb/m_abook.sh.in
@@ -0,0 +1,39 @@
+#! @SH@
+#
+# -*-sh-mode-*-
+#
+#     Copyright (C) 2000 Ross Campbell <rcampbel@us.oracle.com>
+#     Copyright (C) 2000-2005 Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_abook.sh.in,v 1.6 2005-10-29 14:48:09 roland Exp $
+
+m_abook_query()
+{
+    ABOOK=@ABOOK@
+
+    if [ -x "$ABOOK" ]		# check whether abook in installed
+    then
+	for book in ${ABOOK_FILES:-$HOME/.abook/addressbook $HOME/.abook.addressbook}
+	do
+	    if [ -f "$book" ]
+	    then
+		$ABOOK --datafile $book --mutt-query "$@" \
+		| sed -e '1d;s/$/	abook/'
+	    fi
+	done
+    fi
+}
diff --git a/share/lbdb/m_addr_email.sh.in b/share/lbdb/m_addr_email.sh.in
@@ -0,0 +1,39 @@
+#! @SH@
+#
+# -*-sh-mode-*-
+#
+#     Copyright (C) 2000 Torsten Jerzembeck <toje@nightingale.ms.sub.org>
+#     Copyright (C) 2000 Ross Campbell <rcampbel@us.oracle.com>
+#     Copyright (C) 2000-2005 Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# This is a frontend to addr-email(1) from the addressbook(1) package,
+# which can be found at http://red.roses.de/~clemens/addressbook/.
+#
+# $Id: m_addr_email.sh.in,v 1.6 2009-06-11 10:56:22 roland Exp $
+
+m_addr_email_query()
+{
+    ADDR_EMAIL=@ADDR_EMAIL@
+
+    if [ -x "$ADDR_EMAIL" ]		# check whether addr-email in installed
+    then
+	$ADDR_EMAIL "$@" \
+	| sed -e 's/^\([^,]*\), \([^:]*\):	\(.*\)$/\3	\1	\2/' \
+	| grep -a '@' || :
+#	| sed -e 's/\(.*\):[ 	]\([^ 	].*$\)/\2	\1	addr-email/'
+    fi
+}
diff --git a/share/lbdb/m_bbdb.sh.in b/share/lbdb/m_bbdb.sh.in
@@ -0,0 +1,68 @@
+#! @SH@
+#
+# -*-sh-mode-*-
+#
+#     Copyright (c) 2001  Utz-Uwe Haus <haus@uuhaus.de> 2001
+#     Copyright (c) 2003  Aaron Kaplan <kaplan@cs.rochester.edu> 
+#     Copyright (c) 2005  Roland Rosenfeld <roland@spinnaker.de>
+#
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_bbdb.sh.in,v 1.9 2009-06-11 10:56:22 roland Exp $
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+
+m_bbdb_query()
+{
+    if [ -f ${LBDB_BBDB_SCRIPT:=$libdir/lbdb_bbdb_query.el} ]
+    then
+	form="(progn (require (quote lbdb-bbdb-query) 
+		              \"$LBDB_BBDB_SCRIPT\") 
+                     (lbdb-bbdb-query \"$@\"))"
+	if [ -z "$GNUCLIENT" ]
+	then
+	    if type gnuclient >/dev/null 2>&1; then
+		GNUCLIENT=gnuclient
+	    fi
+        fi
+	if [ "$GNUCLIENT" = "no" ]; then
+	    GNUCLIENT=
+	fi
+
+
+	success=0
+	if [ -n "$GNUCLIENT" ] ; then
+	   if $GNUCLIENT -batch -eval "$form" 2> /dev/null; then
+	       success=1
+	   fi
+        fi
+	if [ $success = 0 ]; then
+	    if [ -z "$EMACS" ]
+	    then
+		if type emacs >/dev/null 2>&1; then
+		    EMACS=emacs
+		elif type xemacs >/dev/null 2>&1; then
+		    EMACS=xemacs
+		fi
+	    fi
+	    if [ -n "$EMACS" ] ; then
+		$EMACS -nw --no-site-file --no-init-file -batch \
+		    --eval "$form"  2>/dev/null
+	    fi
+	fi
+    fi |  grep -va '^$' || :
+}
diff --git a/share/lbdb/m_evolution.sh.in b/share/lbdb/m_evolution.sh.in
@@ -0,0 +1,83 @@
+#! @SH@
+#
+# -*-sh-*-
+#
+#     m_evolution - Evolution Address book module for lbdb
+#     Copyright (C) 2004 Guido Guenther <agx@sigxcpu.org>
+#     Copyright (C) 2004-2011 Roland Rosenfeld <roland@spinnaker.de>
+#     Copyright (C) 2008 brian m. carlson <sandals@crustytoothpaste.ath.cx>
+#     Copyright (C) 2009 Jan Larres <jan@majutsushi.net>
+#
+#     loosely based on m_gnomecard
+#
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+
+m_evolution_query ()
+{
+    AWK=@AWK@
+    EVOLUTION_ADDRESSBOOK_EXPORT=@EVOLUTION_ADDRESSBOOK_EXPORT@
+
+    if [ "$EVOLUTION_ADDRESSBOOK_EXPORT" = "auto" ]; then
+	for e in /usr/lib/evolution/*/evolution-addressbook-export
+	do
+	    if [ -x $e ]; then
+		EVOLUTION_ADDRESSBOOK_EXPORT=$e
+	    fi
+	done
+    fi
+
+    if [ -x $EVOLUTION_ADDRESSBOOK_EXPORT ]; then
+        $EVOLUTION_ADDRESSBOOK_EXPORT 2>/dev/null \
+        | $AWK 'BEGIN {
+                    FS = ":"
+                    RS = "\r\n"
+                    name = ""
+                    emails = ""
+                    last_email = 0
+                }
+                /^END:VCARD/ {
+                    if ((name != "" || fileas != "") && emails != "") {
+                        sub("^#", "", emails)
+                        split(emails, emails_arr, "#")
+                        for (email in emails_arr)
+                            printf("%s\t%s\tEV:%s\n",emails_arr[email],name,fileas)
+                    }
+                    name = ""; fileas = ""; emails = ""
+                }
+                /^FN:/ {
+                    name = $2
+                }
+                /^X-EVOLUTION-FILE-AS:/ {
+                    fileas = $2
+                    gsub("\\\\", "", fileas)
+                }
+                # DEST-EMAIL is needed to skip addresses in list contacts
+                /^EMAIL[;:]/ && ! /X-EVOLUTION-DEST-EMAIL/ {
+                    emails = emails "#" $2
+                    last_email = 1
+                }
+                # only join email lines for performance reasons
+                /^ [^ ]/ && last_email == 1 {
+                    cont = $1
+                    sub("^ ", "", cont)
+                    emails = emails cont
+                }
+                ! /^EMAIL[;:]/ && ! /^ [^ ]/ {
+                    last_email = 0
+                }' \
+        | grep -ia "$@" || :
+    fi
+}
diff --git a/share/lbdb/m_fido.sh.in b/share/lbdb/m_fido.sh.in
@@ -0,0 +1,30 @@
+#! @SH@
+#
+# -*-sh-*-
+#
+# $Id: m_fido.sh.in,v 1.8 2009-06-11 10:56:22 roland Exp $
+#
+#     Copyright (C) 1998-2005  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+
+m_fido_db=$HOME/.lbdb/nodelist
+
+m_fido_query()
+{
+    test -f $m_fido_db || return
+    grep -ia "$@." $m_fido_db || :
+}
diff --git a/share/lbdb/m_finger.sh.in b/share/lbdb/m_finger.sh.in
@@ -0,0 +1,51 @@
+#! @SH@
+
+# -*-sh-mode-*-
+
+#     Copyright (C) 1998  Thomas Roessler <roessler@guug.de>
+#     Copyright (C) 2005  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+
+# $Id: m_finger.sh.in,v 1.10 2009-06-11 10:56:22 roland Exp $
+
+m_finger_query()
+{
+    FINGER=@FINGER@
+
+    if [ -x "$FINGER" ]		# check whether finger in installed
+    then
+
+	f_user="`echo \"$@\" | sed 's/@.*//'`"
+	
+	if test "x$M_FINGER_HOSTS" = x ; then
+		M_FINGER_HOSTS="localhost"
+	fi
+
+	for host in $M_FINGER_HOSTS ; do
+	    if test "$host" = "localhost" ; then
+		athost=""
+		mailhost="`lbdb_hostname`"
+	    else
+		athost="@$host"
+		mailhost="$host"
+	    fi
+	    $FINGER $f_user$athost 2> /dev/null \
+	    | sed -n -e "s/^Login: *\([^ ]*\)[ 	]*Name: \(.*\)$/\1@$mailhost	\2	(finger)/p" \
+		     -e "s/^Login name: *\([^ ]*\)[ 	]*In real life: \(.*\)$/\1@$mailhost	\2	(finger)/p" \
+	    | grep -av 'In real life: ???' || :
+	 done
+    fi
+}
diff --git a/share/lbdb/m_getent.sh.in b/share/lbdb/m_getent.sh.in
@@ -0,0 +1,37 @@
+#! @SH@
+#
+# -*-sh-*-
+#
+#     Copyright (C) 2000-2001 Ross Campbell <rcampbel@us.oracle.com>
+#     Copyright (C) 2000-2005 Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_getent.sh.in,v 1.5 2005-10-29 14:48:09 roland Exp $
+
+m_getent_query()
+{
+    GETENT=@GETENT@
+
+    if [ -x "$GETENT" ]	#check for getent
+    then
+	f_user="`echo \"$@\" | sed -e 's/@.*//'`"
+	HOST="`lbdb_hostname`"
+
+	$GETENT passwd \
+	| grep -ia "$f_user" \
+	| sed -e "s/^\([^:]*\):[^:]*:\([^:]*\):[^:]*:\([^:,]*\)[,:].*\$/\1@$HOST	\3	UID \2/"
+    fi
+}
diff --git a/share/lbdb/m_gnomecard.sh.in b/share/lbdb/m_gnomecard.sh.in
@@ -0,0 +1,71 @@
+#! @SH@
+#
+# -*-sh-*-
+#
+#     m_gnomecard - GnomeCard Address book module for lbdb
+#     Copyright (C) 2000 Rick Frankel <rick@rickster.com>
+#                   2000-2005 Roland Rosenfeld <roland@spinnaker.de>
+#
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_gnomecard.sh.in,v 1.9 2009-06-11 10:56:22 roland Exp $
+#
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+AWK=@AWK@
+
+rcfile=$HOME/.gnome/GnomeCard
+
+m_gnomecard_query ()
+{
+    if [ -z "$GNOMECARD_FILES" ]
+    then 
+	if [ -r "$rcfile" ]
+	then
+	    GNOMECARD_FILES=`\
+		$AWK 'BEGIN {FS="="; infile=0} \
+		      /^\[.*\]/ {infile=0} \
+		      /^\[file\]/ {infile=1} \
+		      infile && /^open=/ {print $2}' \
+		    < $rcfile`
+	fi
+	if [ -z "$GNOMECARD_FILES" ]
+	then
+	    GNOMECARD_FILES="$HOME/.gnome/GnomeCard.gcrd"
+	fi
+    fi
+    
+    for file in $GNOMECARD_FILES
+    do
+	if [ $file = ${file#/} ]
+	then
+	    file=$HOME/$file
+	fi
+
+	if [ -f $file ]
+	then
+	    $AWK 'BEGIN {FS=":"; RS="\r\n"; name=""} \
+		  /^END:VCARD/ {name=""} \
+		  /^FN[:;]/ {name=$2} \
+		  name!="" && /^EMAIL;/ {email=$2; \
+					 type=substr($1,7); \
+					 printf ("%s\t%s\tGC:%s\n", \
+						 email, name, type) }' \
+            < $file | grep -ia "$@" || :
+	fi
+    done
+}
diff --git a/share/lbdb/m_gpg.sh.in b/share/lbdb/m_gpg.sh.in
@@ -0,0 +1,42 @@
+#! @SH@
+#
+# -*-sh-*-
+#
+#     Copyright (C) 1998-2005  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_gpg.sh.in,v 1.26 2009-06-11 10:56:22 roland Exp $
+#
+
+m_gpg_query()
+{
+    GPG=@GPG@
+
+    if [ -x "$GPG" ]
+    then
+	$GPG --list-keys --with-colons "$@" 2>/dev/null \
+	| grep -a '^\(pub\|uid\):[^re]:\([^:]*:\)\{7,7\}[^<>:]* <[^<>@: ]*@[^<>@: ]*>[^<>@:]*:' \
+	| sed -e 's/^\([^:]*:\)\{9,9\}\([^<:]*\) <\([^>:]*\)>.*:.*$/\3	\2	(GnuPG)/' \
+	| sed -e 's/	\([^	]\{27,27\}\)[^	]*	/	\1...	/' \
+        | grep -ia "$@" || :
+
+#	$GPG --list-keys --no-greeting "$@" 2>/dev/null \
+#	| grep -a '^\(pub\|uid\)  .\{25,25\} [^<>]* <[^<>@ ]*@[^<>@ ]*>' \
+#	| sed -e 's/^.\{24,31\}\([^<]*\) <\([^>]*\)>.*$/\2	\1	(GnuPG)/' \
+#	| sed -e 's/	\([^	]\{27,27\}\)[^	]*	/	\1...	/' \
+#	| grep -ia "$@"
+    fi
+}
diff --git a/share/lbdb/m_inmail.sh.in b/share/lbdb/m_inmail.sh.in
@@ -0,0 +1,34 @@
+#! @SH@
+#
+#     Copyright (C) 1998-2000  Thomas Roessler <roessler@guug.de>
+#                   1999-2005  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_inmail.sh.in,v 1.14 2009-06-11 10:56:22 roland Exp $
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+
+m_inmail_db=$HOME/.lbdb/m_inmail.list
+
+m_inmail_query()
+{
+	export SORT_OUTPUT
+	$libdir/lbdb-munge
+	test -f $m_inmail_db  || return
+	grep -ia "$@." $m_inmail_db || :
+}
diff --git a/share/lbdb/m_ldap.sh.in b/share/lbdb/m_ldap.sh.in
@@ -0,0 +1,39 @@
+#! @SH@
+#
+# -*-sh-*-
+#
+#     m_ldap - ldap module for lbdb
+#     Copyright (C) 2001 Marc de Courville <marc@courville.org>
+#
+#     $Id: m_ldap.sh.in,v 1.6 2009-06-11 10:56:22 roland Exp $
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+
+m_ldap_query ()
+{
+    if [ "$LDAP_NICKS" != "" ]
+    then
+	for NICK in $LDAP_NICKS
+	do
+	    $libdir/mutt_ldap_query --lbdb_output --nickname=$NICK "$@" || :
+	done
+    else
+	$libdir/mutt_ldap_query --lbdb_output "$@" || :
+    fi
+}
diff --git a/share/lbdb/m_muttalias.sh.in b/share/lbdb/m_muttalias.sh.in
@@ -0,0 +1,46 @@
+#! @SH@
+#
+# -*-sh-*-
+#
+#     Copyright (C) 2000  Brian Salter-Duke <b_duke@bigpond.net.au>
+#                   2000-2007  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_muttalias.sh.in,v 1.11 2009-06-11 10:56:22 roland Exp $
+
+m_muttalias_query()
+{
+    [ -d ${MUTT_DIRECTORY:=$HOME/.mutt} ] || MUTT_DIRECTORY=$HOME
+
+    for file in ${MUTTALIAS_FILES:-.muttrc .mail_aliases muttrc aliases} ; do
+	if [ $file = ${file#/} ]
+	then
+	    file=$MUTT_DIRECTORY/$file
+	fi
+
+	if [ -f "$file" ]
+	then
+	    grep -ia "$@" $file \
+	    | grep -a '^alias[ 	][ 	]*[^,][^,]*[ 	][ 	]*\([^,]\|\\\".*\\\"\)*$' \
+	    | sed -e 's/^alias[ 	][ 	]*\([^ 	][^ 	]*\)[ 	][ 	]*<\([^ 	>][^ 	>]*\)>[ 	][ 	]*(\([^<>()]*\))[^()<>]*$/\2	\3	alias \1/' \
+		  -e 's/^alias[ 	][ 	]*\([^ 	][^ 	]*\)[ 	][ 	]*\(\\\".*\\\"[^<>()]*\|[^<>()]*\)<\([^<>()]*\)>[^<>]*$/\3	\2	alias \1/' \
+	          -e 's/^alias[ 	][ 	]*\([^ 	][^ 	]*\)[ 	][ 	]*\([^<>()]*\)(\(\\\".*\\\"[^<>()]*\|[^<>()]*\))[^()<>]*$/\2	\3	alias \1/' \
+		  -e 's/\\\"//g' \
+	    | grep -va '^alias[ 	][ 	]*[^,][^,]*[ 	][ 	]*[^,]*$' || :
+	fi  
+    done
+}
+
diff --git a/share/lbdb/m_nispasswd.sh.in b/share/lbdb/m_nispasswd.sh.in
@@ -0,0 +1,38 @@
+#! @SH@
+#
+# -*-sh-mode-*-
+#
+#     Copyright (C) 2000 Ross Campbell <rcampbel@us.oracle.com>
+#     Copyright (C) 2000-2005 Roland Rosenfeld <roland@spinnaker.de>
+#     Copyright (C) 2001 Utz-Uwe Haus <haus@uuhaus.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_nispasswd.sh.in,v 1.4 2005-10-29 14:48:10 roland Exp $
+
+m_nispasswd_query()
+{
+    NISCAT=@NISCAT@
+
+    if [ -x "$NISCAT" ]	#check for niscat
+    then
+	f_user="`echo \"$@\" | sed -e 's/@.*//'`"
+	HOST="`lbdb_hostname`"
+
+	$NISCAT passwd.org_dir \
+	| grep -ia "$f_user" \
+	| sed -e "s/^\([^:]*\):[^:]*:\([^:]*\):[^:]*:\([^:,]*\)[,:].*\$/\1@$HOST	\3	UID \2/"
+    fi
+}
diff --git a/share/lbdb/m_osx_addressbook.sh.in b/share/lbdb/m_osx_addressbook.sh.in
@@ -0,0 +1,28 @@
+#! @SH@
+#
+# -*-sh-*-
+#
+#     Copyright (C) 2003  Brendan Cully <brendan@kublai.com>
+#     Copyright (C) 2005  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+
+libdir=@libdir@
+
+m_osx_addressbook_query()
+{
+  $libdir/ABQuery "$@" | grep -ia "$@" || :
+}
diff --git a/share/lbdb/m_palm.sh.in b/share/lbdb/m_palm.sh.in
@@ -0,0 +1,34 @@
+#! @SH@
+#
+# -*-sh-*-
+#
+#     m_palm - Palm address database module for lbdb
+#     Copyright (C) 2000 Dave Pearson <davep@davep.org>
+#     Copyright (C) 2005 Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_palm.sh.in,v 1.8 2009-06-11 10:56:22 roland Exp $
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+
+m_palm_query ()
+{
+    palmdatabase=${PALM_ADDRESS_DATABASE:-$HOME/.jpilot/AddressDB.pdb}
+    test -f $palmdatabase || return
+    $libdir/palm_lsaddr $palmdatabase | grep -ia "$@" || :
+}
diff --git a/share/lbdb/m_passwd.sh.in b/share/lbdb/m_passwd.sh.in
@@ -0,0 +1,38 @@
+#! @SH@
+#
+# -*-sh-*-
+#
+#     Copyright (C) 1999-2005  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_passwd.sh.in,v 1.13 2009-06-11 10:56:22 roland Exp $
+#
+
+m_passwd_query()
+{
+    HOST="`lbdb_hostname`"
+    case "$PASSWD_IGNORESYS" in
+	true|yes|1)
+	    IGNORESYS='UID \([12]....\|....\)$'
+	    ;;
+        *)
+	    IGNORESYS='.'
+	    ;;
+    esac
+
+    sed -e "s/^\([^:]*\):[^:]*:\([^:]*\):[^:]*:\([^:,]*\)[,:].*\$/\1@$HOST	\3	UID \2/" /etc/passwd \
+    | grep -ia "$@" | grep -a "$IGNORESYS" || :
+}
diff --git a/share/lbdb/m_pgp2.sh.in b/share/lbdb/m_pgp2.sh.in
@@ -0,0 +1,35 @@
+#! @SH@
+#
+# -*-sh-*-
+#
+#     Copyright (C) 1998-2005  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_pgp2.sh.in,v 1.11 2005-10-29 14:48:10 roland Exp $
+#
+
+m_pgp2_query()
+{
+    PGP=@PGP@
+    
+    if [ -x "$PGP" ]
+    then
+	$PGP +language=en -kv "$@" 2>/dev/null \
+	| grep -a '^[^<>]\{32,\} <[^<>@:/ ]*@[^<>@ ]*>[^<>@]*$' \
+	| sed -e 's/^.\{30,30\}\(.*\) <\([^:]*\)>.*$/\2	\1	(PGP2)/' \
+	| sed -e 's/	\([^	]\{27,27\}\)[^	]*	/	\1...	/'
+    fi
+}
diff --git a/share/lbdb/m_pgp5.sh.in b/share/lbdb/m_pgp5.sh.in
@@ -0,0 +1,36 @@
+#! @SH@
+#
+# -*-sh-*-
+#
+#     Copyright (C) 1999-2005  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_pgp5.sh.in,v 1.13 2009-06-11 10:56:22 roland Exp $
+#
+
+m_pgp5_query()
+{
+    PGPK=@PGPK@
+
+    if [ -x "$PGPK" ]
+    then
+	$PGPK +language=en -l "$@" 2>/dev/null \
+	| grep -a '^uid  ...* <[^<>@:/ ]*@[^<>@ ]*>[^<>@]*$' \
+	| sed -e 's/^uid  \(.*\) <\(.*\)>.*$/\2	\1	(PGP5)/' \
+	| sed -e 's/	\([^	]\{27,27\}\)[^	]*	/	\1...	/' \
+	| grep -ia "$@" || :
+    fi
+}
diff --git a/share/lbdb/m_pine.sh.in b/share/lbdb/m_pine.sh.in
@@ -0,0 +1,132 @@
+#! @SH@
+#
+# -*-sh-*-
+#
+#     Copyright (C) 2000  Gabor Fleischer <flocsy@mtesz.hu>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_pine.sh.in,v 1.10 2005-10-29 14:48:10 roland Exp $
+
+# m_pine for lbdb v0.9 by Gabor Fleischer <flocsy@mtesz.hu>
+#
+# Two variabled can be set in lbdbrc: PINERC, PINE_ADDRESSBOOKS
+# Here comes the explanation what are they for:
+# 1. First I look for $PINERC. If not set, then I use my defaults:
+#    PINERC="/etc/pine.conf /etc/pine.conf.fixed .pinerc"
+#    If you don't want me to look in the default PINERCs, then set PINERC=no
+# 2. I make a list of all the addressbooks in the PINERCs.
+# 3. Then the $PINE_ADDRESSBOOKS are added to this list.
+# 4. And if this list is still empty then add the default addressbooks:
+#    PINE_ADDRESSBOOKS="/etc/addressbook .addressbook"
+# 5. Make the query in the listed addressbooks
+#
+# Changelog:
+# 0.9: Convert Quoted-Printable in the real names into plain 8bit.
+# 0.8: When the 'real name' is missing, put " " there, so mutt works fine.
+# 0.7: Fixed bugs:
+#	* Search was case sensitive. Now it's insensitive.
+#	* Lines with missing fields (i.e."nick<tab><tab>addr") were broken.
+#	* Default didn't work if address-books in pinercs were "".
+# 0.6: The .addressbook format's multi-line addresses are supported.
+# 0.5: Initial release.
+#
+
+AWK=@AWK@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+qpto8bit=@libdir@/qpto8bit
+
+m_pine_query()
+{
+    addressbooks=
+    if [ x$PINERC != xno ] ; then
+	for pinerc in ${PINERC:-/etc/pine.conf /etc/pine.conf.fixed .pinerc}
+	do
+	    if [ $pinerc = ${pinerc#/} ] ; then
+	        pinerc=$HOME/$pinerc
+	    fi
+	    if [ -f $pinerc ] ; then
+		addressbook=`\
+		    $AWK 'BEGIN {SPACE="";} \
+		    /^(global-)?address-book[ 	]*=/ { \
+			sub("^(global-)?address-book[ 	]*=",""); \
+			while (/[ 	]*[^ 	]+[ 	]+([^ ,	]+)[ 	]*,/) { \
+			    sub("[ 	]*[^ 	]+[ 	]+",""); \
+			    sub("[ ,	].*",""); \
+			    printf("%s%s",SPACE,$0); \
+			    SPACE=" "; \
+			    getline; \
+			} \
+			sub("[ 	]*[^ 	]+[ 	]+",""); \
+			sub("[ 	].*",""); \
+			printf("%s%s",SPACE,$0); \
+			SPACE=" "; \
+		    }' < $pinerc`
+	    fi
+	    addressbooks="${addressbook# } ${addressbooks# }"
+        done
+    fi
+    addressbooks="${PINE_ADDRESSBOOKS} ${addressbooks# }"
+    addressbooks=${addressbooks# }
+    for file in ${addressbooks:=/etc/addressbook .addressbook} ; do
+	if [ $file = ${file#/} ] ; then
+	    file=$HOME/$file
+	fi
+	if [ -f $file ]
+	then
+	    cat $file | $qpto8bit | $AWK -v find="$@" '\
+	    function out() { \
+		if (match(tolower(line),low_find)) {
+		    #order: nick full addr fcc comm \
+		    R[1] = "^[^	]*"; \
+		    R[2] = "^[^	]*	[^	]*"; \
+		    R[3] = "^[^	]*	[^	]*	\\(?[^	]*\\)?"; \
+		    R[4] = "^[^	]*	[^	]*	[^	]*	[^	]*"; \
+		    R[5] = "^[^	]*	[^	]*	[^	]*	[^	]*	[^	]*"; \
+		    beg = 1; \
+		    for (i=1;i<=5;i++) { \
+			match(line,R[i]); \
+			A[i] = substr(line,beg,RLENGTH-beg+1); \
+			beg = RLENGTH+2; \
+		    } \
+		    if (A[2] == "") {A[2] = " "} \
+		    if (match(A[3],/\(.*\)/)) {A[3] = substr(A[3],2,length(A[3])-2)} \
+		    if (A[5] != "") {A[5] = " [" A[5] "]"} \
+		    printf "%s	%s	%s%s (pine)\n",A[3],A[2],A[1],A[5]; \
+		} \
+	    } \
+	    BEGIN { \
+		FS="	"; \
+		low_find = tolower(find); \
+		getline; \
+		while (/^#DELETED/) {getline} ; \
+		line = $0 \
+	    } \
+	    $0 !~ /^#DELETED/ { \
+		if (/^   /) { \
+		    gsub("   ",""); \
+		    line = line $0; \
+		} else { \
+		    out(); \
+		    line = $0; \
+		} \
+	    } \
+	    END { \
+		out() \
+	    }'
+	fi
+    done
+}
diff --git a/share/lbdb/m_vcf.sh.in b/share/lbdb/m_vcf.sh.in
@@ -0,0 +1,44 @@
+#! @SH@
+#
+#     Copyright (C) 2005  Brendan Cully <brendan@kublai.com>
+#     Copyright (C) 2011  Jamey Sharp <jamey@minilop.net>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_vcf.sh.in,v 1.5 2011-06-25 14:22:09 roland Exp $
+
+m_vcf_query()
+{
+  VCQ=@libdir@/vcquery
+
+  QUERY="$1"
+
+  for file in $VCF_FILES
+  do
+    if test -r $file.cache -a $file.cache -nt $file
+    then
+      cmd="cat $file.cache"
+    else
+      if $VCQ $file > $file.cache
+      then
+        cmd="cat $file.cache"
+      else
+        cmd="$VCQ $file"
+      fi
+    fi
+
+    $cmd | grep -ie "$QUERY" | sed 's/(null)$/ /; s/	$/	(VCF)/'
+  done
+}
diff --git a/share/lbdb/m_wanderlust.sh.in b/share/lbdb/m_wanderlust.sh.in
@@ -0,0 +1,33 @@
+#! @SH@
+## -*- sh -*-
+##
+## Copyright (C) 2002 Gergely Nagy <algernon@debian.org>
+## Copyright (C) 2002-2005 Roland Rosenfeld <roland@spinnaker.de>
+##
+## 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_wanderlust.sh.in,v 1.7 2009-06-11 10:56:22 roland Exp $
+
+m_wanderlust_query()
+{
+    addresses=${WANDERLUST_ADDRESSES:-${HOME}/.addresses}
+
+    if [ -f $addesses ]
+    then
+	grep -ia "$@" $addresses \
+	| sed -e 's,^\([^ 	]\+\)[ 	]\+"\([^"]*\)"[ 	]\+"\([^"]\+\)",\1	\3	wl \2,g' \
+	| grep -a '^[^	][^	]*	[^	][^	]*	wl ' || :
+    fi
+}
diff --git a/share/lbdb/m_yppasswd.sh.in b/share/lbdb/m_yppasswd.sh.in
@@ -0,0 +1,37 @@
+#! @SH@
+#
+# -*-sh-mode-*-
+#
+#     Copyright (C) 2000 Ross Campbell <rcampbel@us.oracle.com>
+#     Copyright (C) 2000-2005 Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: m_yppasswd.sh.in,v 1.5 2005-10-29 14:48:11 roland Exp $
+
+m_yppasswd_query()
+{
+    YPCAT=@YPCAT@
+
+    if [ -x "$YPCAT" ]	#check for ypcat
+    then
+	f_user="`echo \"$@\" | sed -e 's/@.*//'`"
+	HOST="`lbdb_hostname`"
+
+	$YPCAT passwd \
+	| grep -ia "$f_user" \
+	| sed -e "s/^\([^:]*\):[^:]*:\([^:]*\):[^:]*:\([^:,]*\)[,:].*\$/\1@$HOST	\3	UID \2/"
+    fi
+}
diff --git a/share/lbdb/munge-keeporder.awk.in b/share/lbdb/munge-keeporder.awk.in
@@ -0,0 +1,41 @@
+#! @AWK@ -f
+#
+# -*-awk-*-
+#
+#     Copyright (C) 1998-2000  Thomas Roessler <roessler@guug.de>
+#                        2000  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: munge-keeporder.awk.in,v 1.3 2005-10-29 14:48:11 roland Exp $
+
+BEGIN {
+    FS = "\t";
+    i = 0;
+}
+
+{
+    line[$1] = $0;
+    pos[$1] = i;
+    idx[i++] = $1;
+}
+
+END {
+    for (j = 0; j < i; j++) {
+	if (pos[idx[j]] == j) {
+	    print line[idx[j]];
+	}
+    }
+}
diff --git a/share/lbdb/munge.awk.in b/share/lbdb/munge.awk.in
@@ -0,0 +1,36 @@
+#! @AWK@ -f
+#
+# -*-awk-*-
+#
+#     Copyright (C) 1998-2000  Thomas Roessler <roessler@guug.de>
+#                   2000-2005  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: munge.awk.in,v 1.7 2005-10-29 14:48:11 roland Exp $
+
+BEGIN {
+    FS = "\t";
+}
+
+{
+    line[$1] = $0;
+}
+
+END {
+    for (a in line) {
+	print line[a];
+    }
+}
diff --git a/share/lbdb/mutt_ldap_query.pl.in b/share/lbdb/mutt_ldap_query.pl.in
@@ -0,0 +1,559 @@
+#! @PERL@ -w
+#
+#     Copyright (C) 2000-2006 Marc de Courville <marc@courville.org>
+#     Copyright (C) 2005-2007 Roland Rosenfeld <roland@spinnaker.de>
+#
+#     $Id: mutt_ldap_query.pl.in,v 1.28 2010-05-18 18:10:30 roland Exp $
+#
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+
+use strict;
+use Getopt::Long;
+use Net::LDAP;
+use Pod::Usage;
+
+#------8<------8<------8<------8<---cut here--->8------>8------>8------>8------
+# The defaults
+my $man = 0;
+my $help = 0;
+my $DEBUG = 0;
+my $lbdb_output = 0;
+my $version = 0;
+my $ldap_server_nickname = '';
+my $config_file = '';
+
+# hostname of your ldap server
+our $ldap_server = 'ldap.four11.com';
+# ldap base search
+our $search_base = 'c=US';
+# list of the fields that will be used for the query
+our $ldap_search_fields = 'givenname sn cn';
+# list of the fields that will be used for composing the answer
+our $ldap_expected_answers = 'givenname sn mail o';
+# format of the email result based on the expected answers of the ldap query
+our $ldap_result_email = '${mail}';
+# format of the realname result based on the expected answers of the ldap query
+our $ldap_result_realname = '${givenname} ${sn}';
+# format of the comment result based on the expected answers of the ldap query
+our $ldap_result_comment = '(${o})';
+# use ignorant (wildcard searching):
+our $ignorant = 0;
+# LDAP bind DN:
+our $ldap_bind_dn = '';
+# LDAP bind password:
+our $ldap_bind_password = '';
+
+our %ldap_server_db = (
+  'four11'		=> ['ldap.four11.com', 'c=US', 'givenname sn cn mail', 'givenname cn sn mail o', '${mail}', '${givenname} ${sn}', '${o}' ],
+  'infospace'		=> ['ldap.infospace.com', 'c=US', 'givenname sn cn mail', 'givenname cn sn mail o', '${mail}', '${givenname} ${sn}', '${o}' ],
+  'whowhere'		=> ['ldap.whowhere.com', 'c=US', 'givenname sn cn mail', 'givenname cn sn mail o', '${mail}', '${givenname} ${sn}', '${o}' ],
+  'bigfoot'		=> ['ldap.bigfoot.com', 'c=US', 'givenname sn cn mail', 'givenname cn sn mail o', '${mail}', '${givenname} ${sn}', '${o}' ],
+  'switchboard'		=> ['ldap.switchboard.com', 'c=US', 'givenname sn cn mail', 'givenname cn sn mail o', '${mail}', '${givenname} ${sn}', '${o}' ],
+  'infospacebiz'	=> ['ldapbiz.infospace.com', 'c=US', 'givenname sn cn mail', 'givenname cn sn mail o', '${mail}', '${givenname} ${sn}', '${o}' ]
+);
+#------8<------8<------8<------8<---cut here--->8------>8------>8------>8------
+
+# Return version string from CVS tag
+sub versionstring {
+  my $ver = ' $Name: debian_version_0_38 $ ';
+  $ver =~ s/Name//g;
+  $ver =~ s/[:\$]//g;
+  $ver =~ s/\s+//g;
+  $ver =~ s/^v//g;
+  $ver =~ s/_/\./g;
+  if ($ver eq '') {
+    $ver = "devel";
+  }
+  return($ver . " <marc\@courville.org>");
+}
+
+# Source a perl file
+sub process_file {
+  foreach my $file (@_) {
+    if (-r $file) {
+      unless (my $return = do $file) {
+	warn "couldn't parse $file: $@" if $@;
+	warn "couldn't do $file: $!" unless defined $return;
+	warn "couldn't run $file" unless $return;
+      }
+    }
+#    else {
+#      warn "either $file doesn't exist or is not readable by me!\n";
+#    }
+  }
+}
+
+# first we need to apply defaults
+process_file("@sysconfdir@/lbdb_ldap.rc",
+             "@sysconfdir@/mutt_ldap_query.rc",
+             "$ENV{HOME}/.lbdb/ldap.rc",
+	     "$ENV{HOME}/.mutt_ldap_query.rc");
+
+
+# Parse command line options. They override system defaults.
+GetOptions (
+  'config_file|c=s'		=> \$config_file,
+  'server|ls=s'			=> \$ldap_server,
+  'search_base|sb:s'		=> \$search_base,
+  'search_fields|sf:s'		=> \$ldap_search_fields,
+  'expected_answers|ea:s'	=> \$ldap_expected_answers,
+  'format_email|fe:s'		=> \$ldap_result_email,
+  'format_realname|fr:s'	=> \$ldap_result_realname,
+  'format_comment|fc:s'		=> \$ldap_result_comment,
+  'nickname|n=s'		=> \$ldap_server_nickname,
+  'bind_dn|bd:s'                => \$ldap_bind_dn,
+  'bind_password|bp:s'          => \$ldap_bind_password,
+  'debug'			=> sub { $DEBUG = 1 },
+  'help|?|h'			=> \$help,
+  'man|m'			=> \$man,
+  'ignorant|i'			=> \$ignorant,
+  'lbdb_output|l'		=> \$lbdb_output,
+  'version|v'			=> \$version
+);
+
+#
+# print usage and help info before we process config files
+#
+pod2usage(1) if $help;
+pod2usage(-verbose => 2) if $man;
+
+if ($version) {
+  print "mutt_ldap_query version " . &versionstring() . "\n";
+  print '$Id: mutt_ldap_query.pl.in,v 1.28 2010-05-18 18:10:30 roland Exp $ ' . "\n";
+  exit(0);
+}
+
+# command-line config file take precedence over command-line options
+if ($config_file) {
+  process_file($config_file);
+}
+
+
+# after we've done with GetOptions $ARGV[0] should present the rest
+# (i.e. mandatory search pattern)
+die pod2usage(1) if (! $ARGV[0] );
+
+if ($ldap_server_nickname) {
+  my $option_array = $ldap_server_db{$ldap_server_nickname};
+  die print "$0 unknown server nickname:\n\t no server associated to the nickname $ldap_server_nickname, please modify the internal database according your needs by editing the ressource file or specifying the relevant one to use\n" if ! $option_array;
+  $ldap_server = $option_array->[0];
+  $search_base = $option_array->[1];
+  $ldap_search_fields = $option_array->[2];
+  $ldap_expected_answers = $option_array->[3];
+  $ldap_result_email = $option_array->[4];
+  $ldap_result_realname = $option_array->[5];
+  $ldap_result_comment = $option_array->[6];
+  if (defined($option_array->[7])) {
+     $ignorant = $option_array->[7];
+  }
+  if (defined($option_array->[8])) {
+     $ldap_bind_dn = $option_array->[8];
+  }
+  if (defined($option_array->[9])) {
+     $ldap_bind_password = $option_array->[9];
+  }
+}
+
+print "DEBUG: ldap_server='$ldap_server' search_base='$search_base' search_fields='$ldap_search_fields'\
+       expected_answer='$ldap_expected_answers' format_email='$ldap_result_email' format_realname='$ldap_result_realname'\
+       bind_dn='$ldap_bind_dn' bind_password='$ldap_bind_password'\n" if ($DEBUG);
+
+my @fields = split / /, $ldap_search_fields;
+my @results;
+
+foreach my $askfor ( @ARGV ) {
+  my $query="";
+  if ($ignorant) {
+# enable this if you want to include wildcard in your search with some huge
+# ldap databases you might want to avoid it
+    $query = join '', map { "($_=*$askfor*)" } @fields;
+  }
+  else {
+    $query = join '', map { "($_=$askfor)" } @fields;
+  }
+  $query = "(|" . $query . ")";
+
+  print "DEBUG: perl ldap module processing filter:\nDEBUG: $query\n" if ($DEBUG);
+  my $ldap = Net::LDAP->new($ldap_server, Debug => 3) or die $@;
+  if (defined($ldap_bind_dn) && $ldap_bind_dn ne ''
+      && defined($ldap_bind_password) && $ldap_bind_password ne '') {
+    $ldap->bind($ldap_bind_dn, password=> $ldap_bind_password);
+  } else {
+    $ldap->bind;
+  }
+  my $mesg = $ldap->search( base => $search_base, filter => $query ) or die $@;
+  if ($mesg->code && ($mesg->code ne '4')) {
+    die "Search failed. LDAP server returned an error : ", $mesg->code, ", description: ", $mesg->error;
+  }
+  my @entries = $mesg->entries;
+  map { $_->dump } $mesg->all_entries if ($DEBUG);
+  my $entry;
+  foreach $entry (@entries) {
+    print "DEBUG: processing $entry->dn\n" if ($DEBUG);
+# prepare the results
+    my @emails = ();
+    my $realname = $ldap_result_realname;
+    my $comment = $ldap_result_comment;
+    foreach my $answer (split / /, $ldap_expected_answers) {
+      my $result = '';
+# if this is email we take all the values
+      if( $ldap_result_email =~ /\${$answer}/ ) {
+        foreach my $result ($entry->get_value($answer)) {
+          my $email = $ldap_result_email;
+          $email =~ s/\${$answer}/$result/g;
+          push @emails, $email;
+        }
+      } 
+      else {
+        my $result = '';
+# if there is no answer must return the null otherwise we get an uninitialized variable error
+        ($result = $entry->get_value($answer)) || ($result = '');
+# replace the containers with the results of the query
+        $realname =~ s/\${$answer}/$result/g;
+        $comment =~ s/\${$answer}/$result/g;
+      }
+    }
+    foreach my $ema (@emails)  {
+       push @results, "$ema\t$realname\t$comment\n";
+    }
+  }
+  $ldap->unbind;
+}
+
+if ($lbdb_output) {
+# display results convenient for lbdb processing
+  print @results;
+}
+else {
+  print "LDAP query: found ", scalar(@results), "\n", @results;
+}
+
+exit 1 if ! @results;
+
+__END__
+
+=head1 NAME
+
+mutt_ldap_query - Query LDAP server for Mutt mail-reader
+
+=head1 SYNOPSIS
+
+mutt_ldap_query.pl [options] <name_to_query> [[<other_name_to_query>] ...]
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<--config=config_file> or B<-c config_file>
+
+specify an alternate resource file other than the system ones
+(F<@sysconfdir@/lbdb_ldap.rc> or F<@sysconfdir@/mutt_ldap_query.rc>)
+or default personal ones (F<$HOME/.lbdb/ldap.rc> or
+F<$HOME/.mutt_ldap_query.rc>).
+
+=item B<--server=ldap_server> or B<-ls ldap_server>
+
+hostname of your ldap server.  You can also use an ldap://foo[:port]
+or ldaps://foo[:port] URL here to talk to different ports or SSL
+encrypted servers.  Or use ldapi://%2fvar%2flib%2fldap_sock to access an
+ldap server via a socket (use %2f as as replacement for a slash in the file
+name).
+
+=item B<--search_base=ldap_search_base> or B<-sb ldap_search_base>
+
+use <search_base> as the starting point for the search instead of the default.
+
+=item B<--search_fields=ldap_search_fields> or B<-sf ldap_search_fields>
+
+list of the fields on which the query will be performed.
+
+=item B<--expected_answers=ldap_expected_answers> or B<-ea ldap_expected_answers>
+
+list of the fields expected as the answer of the ldap server that will
+be used for composing the output of the script.
+
+=item B<--format_email=result_format_email> or B<-fe result_format_email>
+
+format to be used for composing the email output result. It has to be
+based on the expected ldap server answers and can use variable
+containers of the form ${variable} where variable belongs to the
+<ldap_expected_answers> set.
+
+=item B<--format_realname=result_format_realname> or B<-fr result_format_realname>
+
+format to be used for composing the realname output result. It has to
+be based on the expected ldap server answers and can use variable
+containers of the form ${variable} where variable belongs to the
+<ldap_expected_answers> set.
+
+=item B<--format_comment=result_format_comment> or B<-fc result_format_comment>
+
+format to be used for composing the comment output result. It has to
+be based on the expected ldap server answers and can use variable
+containers of the form ${variable} where variable belongs to the
+<ldap_expected_answers> set.
+
+=item B<--bind_dn=bind_distinguished_name> or B<-bd bind_distinguished_name>
+
+the destinguished name of the user who binds to the LDAP server.
+Leave it empty for an anonmyous bind.
+
+=item B<--bind_password=secret> or B<-bp secret>
+
+the bind password for binding to the LDAP server.
+Leave it empty for an anonmyous bind.
+
+=item B<--nickname=ldap_server_nickname> or B<-n ldap_server_nickname>
+
+shortcut for avoiding to use all the previous options by using the
+script builtin or alternate config file table of common servers and
+associated options.  All the required parameters are then derived by
+performing a <lbdb_server_nickname> lookup.
+
+=item B<--debug> or B<-d>
+
+turn on debugging messages.
+
+=item B<--help> or B<-?> or B<-h> or B<--man> or B<-m>
+
+generates this help message.
+
+=item B<--ignorant> or B<-i>
+
+ignorant mode: search using wildcard for *name_to_query* (requires a
+longer processing from LDAP server but is quite convenient :).
+
+=item B<--lbdb_output> or B<-l>
+
+suppress number of matches output (suited for interfacing with little
+brother database http://www.spinnaker.de/lbdb/).
+
+=item B<--version> or B<-v>
+
+show the version.
+
+=back
+
+=head1 DESCRIPTION
+
+B<mutt_ldap_query> performs ldap queries using either ldapsearch command
+or the perl-ldap module and it outputs the required formatted data for
+feeding mutt when using its "External Address Query" feature.
+
+The output of the script consists in 3 fields separated with tabs: the
+email address, the name of the person and a comment.
+
+=head1 INTERFACING WITH MUTT
+
+This perl script can be interfaced with mutt by defining in your .muttrc:
+
+    set query_command = "mutt_ldap_query.pl %s"
+
+Multiple requests are supported: the "Q" command of mutt accepts as argument
+a list of queries (e.g. "Gosse de\ Courville").
+
+Alternatively mutt_ldap_query can be interfaced with the more generic
+little brother database query program (http://www.spinnaker.de/lbdb/)
+using:
+
+    set query_command = "lbdbq %s"
+
+and by specifying in your ~/.lbdb/lbdbrc file another method of query
+just adding to the METHODS variable the m_ldap module e.g.:
+
+    METHODS='m_inmail m_passwd m_ldap m_muttalias m_finger'
+
+and the right path to access m_ldap in MODULES_PATH, e.g. if you moved
+F<m_ldap> in F<~/.lbdb/modules>:
+
+    MODULES_PATH="/usr/local/lib $HOME/.lbdb/modules"
+
+Just make sure to use the correct path for calling mutt_ldap_query
+in the m_ldap script.
+
+=head1 RESOURCE FILE FORMAT
+
+mutt_ldap_query is now fully customizable using an external resource
+file. By default mutt_ldap_query parses the system definition file
+located generally at F</etc/mutt_ldap_query.rc> or
+F</usr/local/etc/mutt_ldap_query.rc> and also the user one:
+F<$HOME/.mutt_ldap_query.rc>.
+
+Instead of using command line options, the user can redefine all the
+variables using the resource file by two manners in order to match his
+site configuration.  A file example is provided below:
+
+    # The format of each entry of the ldap server database is the following:
+    # LDAP_NICKNAME => ['LDAP_SERVER', 
+    #                   'LDAP_SEARCH_BASE',
+    #                   'LDAP_SEARCH_FIELDS',
+    #                   'LDAP_EXPECTED_ANSWERS',
+    #                   'LDAP_RESULT_EMAIL',
+    #                   'LDAP_RESULT_REALNAME',
+    #                   'LDAP_RESULT_COMMENT'],
+    
+    # a practical illustrating example being:
+    #  debian	=> ['db.debian.org',
+    #               'ou=users,dc=debian,dc=org',
+    #               'uid cn sn ircnick',
+    #               'uid cn sn ircnick',
+    #               '${uid}@debian.org',
+    #               '${cn} ${sn}',
+    #               '${ircnick}'],
+    # the output of the query will be then: 
+    # ${uid}@debian.org\t${cn} ${sn}\t${ircnick} (i.e.: email name comment)
+    
+    # warning this database will erase default script builtin
+    %ldap_server_db = (
+      'four11'		=> ['ldap.four11.com',
+                            'c=US',
+                            'givenname sn cn mail',
+                            'givenname cn sn mail o',
+                            '${mail}',
+                            '${givenname} ${sn}',
+                            '${o}' ],
+      'infospace'	=> ['ldap.infospace.com',
+                            'c=US',
+                            'givenname sn cn mail',
+                            'givenname cn sn mail o',
+                            '${mail}',
+                            '${givenname} ${sn}',
+                            '${o}' ],
+      'whowhere'	=> ['ldap.whowhere.com',
+                            'c=US',
+                            'givenname sn cn mail',
+                            'givenname cn sn mail o',
+                            '${mail}',
+                            '${givenname} ${sn}',
+                            '${o}' ],
+      'bigfoot'		=> ['ldap.bigfoot.com',
+                            'c=US',
+                            'givenname sn cn mail'
+                           , 'givenname cn sn mail o'
+                           , '${mail}'
+                           , '${givenname} ${sn}',
+                            '${o}' ],
+      'switchboard'	=> ['ldap.switchboard.com',
+                            'c=US',
+                            'givenname sn cn mail'
+                           , 'givenname cn sn mail o',
+                            '${mail}',
+                            '${givenname} ${sn}',
+                            '${o}' ],
+      'infospacebiz'	=> ['ldapbiz.infospace.com',
+                            'c=US',
+                            'givenname sn cn mail',
+                            'givenname cn sn mail o',
+                            '${mail}',
+                            '${givenname} ${sn}',
+                            '${o}' ],
+    );
+    
+    # hostname of your ldap server
+    $ldap_server = 'ldap.four11.com';
+    # ldap base search
+    $search_base = 'c=US';
+    # list of the fields that will be used for the query
+    $ldap_search_fields = 'givenname sn cn mail';
+    # list of the fields that will be used for composing the answer
+    $ldap_expected_answers = 'givenname sn cn mail o';
+    # format of the email result based on the expected answers of the ldap query
+    $ldap_result_email = '${mail}';
+    # format of the realname result based on the expected answers of the ldap query
+    $ldap_result_realname = '${givenname} ${sn}';
+    # format of the comment result based on the expected answers of the ldap query
+    $ldap_result_comment = '(${o})';
+
+=head1 EXAMPLES OF QUERIES
+
+    mutt_ldap_query.pl --ldap_server='ldap.mot.com' \
+       --search_base='ou=employees, o=Motorola,c=US' \
+       --ldap_search_fields='commonName gn sn cn uid' \
+       --ldap_expected_answers='gn sn preferredRfc822Recipient ou c telephonenumber' \
+       --ldap_result_email='${preferredRfc822Recipient}' \
+       --ldap_result_realname='${gn} ${sn}' \
+       --ldap_result_comment='(${telephonenumber}) ${ou} ${c}' \
+       Gosse de\ Courville
+
+performs a query using the ldap server ldap.mot.com using
+the following searching base 'ou=employees, o=Motorola,c=US' and
+performing a search on the fields 'commonName gn sn cn uid' for 'Gosse'
+and then "de Courville" looking for the following answers 'gn sn
+preferredRfc822Recipient ou c telephonenumber'. Based on this answers,
+mutt_ldap_query will return a list of entries identified of the form:
+
+  <${preferredRfc822Recipient}>\t${gn} ${sn}\t(${telephonenumber}) ${ou} ${c}
+
+where ${} variables should be considered as containers that are
+replaced by the results of the query. The previous query can be
+greatly simplified by using the ldap server mini database feature of
+the resource file introducing for example a nickname.
+
+    mutt_ldap_query.pl --ldap_server_nickname='motorola' Gosse de\ Courville
+
+When not sure of the full name (i.e. it should contain Courville)
+the ignorant mode is useful since the query will be performed using
+wildcards, i.e. *Courville* in the following case:
+
+    mutt_ldap_query.pl --ignorant Courville
+
+=head1 WHERE TO GET IT
+
+The latest version can be retrieved at
+  ftp://ftp.mutt.org/pub/mutt/contrib
+or
+  http://www.courville.org/
+
+Note that now the script is integrated in the latest version of the little brother database available at http://www.spinnaker.de/lbdb/.  It is thus easier to use through this standard package than to hand customize it to fit your system/distribution needs.
+
+=head1 REFERENCES
+
+=over 2
+
+=item -
+
+perl-ldap module
+ http://perl-ldap.sourceforge.net/
+
+=item -
+
+mutt is the ultimate email client
+ http://www.mutt.org/
+
+=item -
+
+historical Brandon Blong's "External Address Query" feature patch for mutt
+ http://www.fiction.net/blong/programs/mutt/#query
+
+=item -
+
+little brother database is an interface query program for mutt that allow
+multiple searches for email addresses based on external query scripts
+just like this one 8-)
+ http://www.spinnaker.de/lbdb/
+
+=back
+
+=head1 AUTHORS
+
+Marc de Courville <marc@courville.org> and the various other contributors... that kindly sent their patches.
+
+Please report any bugs, or post any suggestions, to <marc@courville.org>.
+
+=head1 COPYRIGHT
+
+Copyright (c) 1998-2003 Marc de Courville <marc@courville.org>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the GNU General Public License (GPL). See http://www.opensource.org/gpl-license.html and http://www.opensource.org/.
+
+=cut
diff --git a/share/lbdb/nodelist2lbdb.man.in b/share/lbdb/nodelist2lbdb.man.in
@@ -0,0 +1,44 @@
+.\" -*-nroff-*-
+.\" Copyright (c) 1999-2005  Roland Rosenfeld <roland@debian.org>
+.\"               
+.\" This manual page 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+.\"
+.TH NODELIST2LBDB 1 "October 2005" Unix "User Manuals"
+.SH NAME
+nodelist2lbdb \- convert Fido nodelist and pointlist to lbdb format
+.SH SYNOPSIS
+.B nodelist2lbdb
+.BI nodelist. XXX
+.BI [point24. XXX ]
+.SH DESCRIPTION
+This little script reads in a Fido named 
+.BI nodelist. XXX
+and optionally a Fido point list named 
+.BI points24. YYY
+and generates a list with the lbdb format:
+.nf
+    <mailaddress> TAB <realname> TAB <comment>
+.fi
+This file is written to
+.I $HOME/.lbdb/nodelist
+.SH FILES
+.I $HOME/.lbdb/nodelist
+.br
+.I @libdir@/m_fido
+.SH "SEE ALSO"
+.BR lbdbq (1)
+.SH AUTHORS
+.B nodelist2lbdb
+is written by Roland Rosenfeld <roland@spinnaker.de>.
diff --git a/share/lbdb/nodelist2lbdb.pl.in b/share/lbdb/nodelist2lbdb.pl.in
@@ -0,0 +1,124 @@
+#! @PERL@
+#
+# -*-perl-*-
+#
+# $Id: nodelist2lbdb.pl.in,v 1.3 2005-10-29 14:48:11 roland Exp $
+#
+# This little script reads Fido nodelist.XXX (and points24.YYY) in and
+# generates a list with the following format from it: 
+# <mailaddress> TAB <realname> TAB <comment>
+# To reduce the size of the generated list, only Region 24 of the
+# nodelist is used.
+#
+# The generated list can be used in combination of Thomas Roessler's
+# lbdb for the Mutt mailreader.
+#
+##########################################################################
+#
+#   Copyright (C) 1998-2005  Roland Rosenfeld <roland@spinnaker.de>
+#
+#   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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+##########################################################################
+
+$database="$ENV{HOME}/.lbdb/nodelist";
+
+if (@ARGV == 0 || @ARGV >2 
+    || !($ARGV[0] =~ /nodelist\.\d\d\d$/i) 
+    || ((@ARGV == 2) && !($ARGV[1] =~ /points24\.\d\d\d$/i ))) {
+  die "Usage: $0 nodelist.XXX [points24.YYY]\n";
+}
+
+open (DB, ">$database") || die "Cannot open $database for writing";
+
+#
+# Process Nodelist:
+#
+
+$zone=2;
+$net=0;
+$node=0;
+
+open (NODELIST, "<$ARGV[0]") || die "Cannot open $ARGV[0]";
+while (<NODELIST>) {
+  next if /^;/;
+  ($special,$number,$bbs,$city,$name) = split(/,/);
+
+  if ($special =~ /Zone/) {
+    $zone=$number;
+    $net=$number;
+    $node=0;
+  } elsif ($special =~ /Region/) {
+    $net=$number;
+    $node=0;
+  } elsif ($special =~ /Host/) {
+    $net=$number;
+    $node=0;
+  } elsif ($special =~ /Down|Hold/) {
+    next;
+  } else {
+    $node = $number;
+  }
+
+  $address = "$name\@f$node.n$net.z$zone.fidonet.org";
+  $name =~ s/_/ /g;
+  $bbs =~ s/_/ /g;
+
+  #
+  # Restrict to Region 24:
+  #
+#  if ($zone =~ /^2$/ && $net =~ /^24/ ) {
+    print DB "$address\t$name\t$bbs\n";
+#  }
+}
+close NODELIST;
+
+
+#
+# Process Pointlist:
+#
+
+$zone=2;
+$net=0;
+$node=0;
+$point=0;
+
+open (POINTLIST, "<$ARGV[1]") || die "Cannot open $ARGV[1]";
+while (<POINTLIST>) {
+  next if /^;/;
+  ($special,$number,$bbs,$city,$name) = split(/,/);
+
+  if ($special =~ /Region/) {
+    next;
+  } elsif ($special =~ /Host/) {
+    ($net,$node) = split(/\//, $bbs);
+    next;
+  } elsif ($special =~ /Down|Hold/) {
+    next;
+  } else {
+    $point = $number;
+  }
+
+  $address = "$name\@p$point.f$node.n$net.z$zone.fidonet.org";
+  $name =~ s/_/ /g;
+  $city =~ s/_/ /g;
+
+  print DB "$address\t$name\t$city\n";
+
+}
+close NODELIST;
+
+
+close DB;
diff --git a/share/lbdb/palm_lsaddr.pl.in b/share/lbdb/palm_lsaddr.pl.in
@@ -0,0 +1,63 @@
+#! @PERL@
+#
+#     palm_lsaddr - Palm address database helper utility for lbdb
+#     Copyright (C) 2000 Dave Pearson <davep@davep.org>
+#               (C) 2003 Nikolaus Rath <Nikolaus@rath.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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+
+use Palm::PDB;
+use Palm::Address;
+
+if ( $#ARGV > -1 )
+{
+    my $pdb = new Palm::PDB;
+
+    if ( $pdb )
+    {
+        $pdb->Load( $ARGV[ 0 ] );
+
+        my $record;
+
+        for ( $i = 0, $record = $pdb->{records}[ $i ]; $record; $i++, $record = $pdb->{records}[ $i ] )
+        {
+            my $name = $record->{fields}{firstName} . " " . $record->{fields}{name};
+
+            # Remove leading and trailing whitespace.
+            $name =~ s/\s+$//;
+            $name =~ s/^\s+//;
+
+            # If the name is empty, use the company name instead.
+            $name = $record->{fields}{company} unless ( length( $name ) > 0 );
+
+            if ( length( $name ) > 0 )
+            {
+                my $entry;
+
+                # Find fields containing e-mail addresses
+                for($entry=1; $entry <= 5; $entry++)
+                {
+                    # 0 = Work, 1 = Home, 2 = Fax, 3 = Other, 4 = email,
+                    # 5 = Main, 6 = Pager, 7 = Mobile
+                    if($record->{phoneLabel}{"phone${entry}"} == 4) {
+                        # A field can also contain multiple lines.
+                        print map "$_\t$name\t(Palm)\n",
+                            split(/\n/, $record->{fields}{"phone${entry}"});
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/share/lbdb/tac.awk.in b/share/lbdb/tac.awk.in
@@ -0,0 +1,37 @@
+#! @AWK@ -f
+#
+# -*-awk-*-
+#
+#     Copyright (C) 2000-2005  Roland Rosenfeld <roland@spinnaker.de>
+# 
+#     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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
+#
+# $Id: tac.awk.in,v 1.3 2005-10-29 14:48:11 roland Exp $
+#
+# Output file in reverse order 
+
+BEGIN {
+    i = 0;
+}
+
+{
+    line[i++] = $0;
+}
+
+END {
+    for (i-- ; i>=0; i--) {
+	print line[i];
+    }
+}