1 ;;; elmo-database.el -- Database module for ELMO.
3 ;; Copyright 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
5 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
6 ;; Keywords: mail, net news
7 ;; Time-stamp: <2000-01-07 00:19:44 teranisi>
9 ;; This file is part of ELMO (Elisp Library for Message Orchestration).
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
35 (defvar elmo-database-msgid nil)
36 (defvar elmo-database-msgid-filename "msgid")
38 (defun elmo-database-get (dbsym dbname)
39 (if (not (and (symbol-value dbsym)
40 (database-live-p (symbol-value dbsym))))
41 (set dbsym (open-database (expand-file-name
45 (symbol-value dbsym)))
47 (defun elmo-database-close ()
48 (and elmo-database-msgid
49 (database-live-p elmo-database-msgid)
50 (close-database elmo-database-msgid)))
52 (defun elmo-database-msgid-put (msgid folder number)
53 (let ((db (elmo-database-get 'elmo-database-msgid
54 elmo-database-msgid-filename)))
57 (remove-database msgid db)
58 (put-database msgid (prin1-to-string
59 (list folder number)) db)))))
61 (defun elmo-database-msgid-delete (msgid)
62 (remove-database msgid (elmo-database-get
64 elmo-database-msgid-filename)))
66 (defun elmo-database-msgid-get (msgid)
67 (let ((match (get-database msgid (elmo-database-get
69 elmo-database-msgid-filename))))
70 (and match (read match))))
72 (provide 'elmo-database)
74 ;;; elmo-database.el ends here