annotate lisp/url/url-wais.el @ 2:ac2d302a0011 r19-15b2

Import from CVS: tag r19-15b2
author cvs
date Mon, 13 Aug 2007 08:46:35 +0200
parents 376386a54a3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; url-wais.el,v --- WAIS Uniform Resource Locator retrieval code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Author: wmperry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Created: 1996/05/24 15:27:12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Version: 1.3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: comm, data, processes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;; Copyright (c) 1993, 1994, 1995 by William M. Perry (wmperry@spry.com)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; This file is not part of GNU Emacs, but the same permissions apply.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (require 'url-vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (require 'url-parse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; WAIS support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; ------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; Here are even more gross hacks that I call native WAIS support.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; This code requires a working waisq program that is fully
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; compatible with waisq from think.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (defun url-create-wais-source (server port dbase)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; Create a temporary wais source description file. Returns the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; file name the description is in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (let ((x (url-generate-unique-filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (y (get-buffer-create " *waisq-tmp*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (set-buffer y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (concat "(:source\n:version 3\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ":ip-name \"%s\"\n:tcp-port %s\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ":database-name \"%s\"\n)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 server (if (equal port "") "210" port) dbase))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (write-region (point-min) (point-max) x nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (kill-buffer y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (defun url-wais-stringtoany (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; Return a wais subelement that specifies STR in any database
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (concat "(:any :size " (length str) " :bytes #( "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (mapconcat 'identity str " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 " ) )"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;(defun url-retrieve-wais-docid (server port dbase local-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ; (call-process "waisretrieve" nil url-working-buffer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ; (format "%s:%s@%s:%s" (url-unhex-string local-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ; dbase server port)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;(url-retrieve-wais-docid "quake.think.com" "210" "directory-of-servers"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ; "0 2608 /proj/wais/wais-sources/vpiej-l.src")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defun url-retrieve-wais-docid (server port dbase local-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; Retrieve a wais document.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; SERVER is the server the database is on (:ip-name in source description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; PORT is the port number to contact (:tcp-port in the source description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; DBASE is the database name (:database-name in the source description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; LOCAL-ID is the document (:original-local-id in the question description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (let* ((dbf (url-create-wais-source server port dbase))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (qstr (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (concat "(:question :version 2\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 " :result-documents\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 " ( (:document-id\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 " :document\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 " (:document\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 " :headline \"\"\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 " :doc-id\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 " (:doc-id :original-database %s\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 " :original-local-id %s )\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 " :number-of-bytes -1\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 " :type \"\"\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 " :source\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 " (:source-id :filename \"%s\") ) ) ) )")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (url-wais-stringtoany dbase)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (url-wais-stringtoany (url-unhex-string local-id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 dbf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (qf (url-generate-unique-filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (set-buffer (get-buffer-create url-working-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (insert qstr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (write-region (point-min) (point-max) qf nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (call-process url-waisq-prog nil url-working-buffer nil "-f" qf "-v" "1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (set-buffer url-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (setq url-current-file (url-unhex-string local-id)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (delete-file dbf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (delete-file qf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (error nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;(url-perform-wais-query "quake.think.com" "210" "directory-of-servers" "SGML")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (defun url-perform-wais-query (server port dbase search)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; Perform a wais query.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;; SERVER is the server the database is on (:ip-name in source description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; PORT is the port number to contact (:tcp-port in the source description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; DBASE is the database name (:database-name in the source description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;; SEARCH is the search term (:seed-words in the question description)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (let ((dbfname (url-create-wais-source server port dbase))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (qfname (url-generate-unique-filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (results 'url-none-gotten))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (url-clear-tmp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (concat "(:question\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 " :version 2\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 " :seed-words \"%s\"\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 " :sourcepath \"" url-temporary-directory "\"\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 " :sources\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 " ( (:source-id\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 " :filename \"%s\"\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 " )\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 " )\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 " :maximum-results 100)\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 search dbfname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (write-region (point-min) (point-max) qfname nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (call-process url-waisq-prog nil url-working-buffer nil "-g" "-f" qfname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (set-buffer url-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (setq url-current-server server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 url-current-port port
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 url-current-file dbase)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (insert-file-contents-literally qfname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (if (re-search-forward "(:question" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (delete-region (point-min) (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (url-replace-regexp "Process.*finished.*" "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (subst-char-in-region (point-min) (point-max) 35 32)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (message "Done reading info - parsing results...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (if (re-search-forward ":result-documents[^(]+" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (while (eq results 'url-none-gotten)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (setq results (read (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (error (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (setq results 'url-none-gotten)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (goto-char (match-end 0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (insert "<title>Results of WAIS search</title>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 "<h1>Searched " dbase " for " search "</h1>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 "<hr>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 "Found <b>" (int-to-string (length results))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 "</b> matches.\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 "<ol>\n<li>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (mapconcat 'url-parse-wais-doc-id results "\n<li>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 "\n</ol>\n<hr>\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (message "No results"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (setq url-current-mime-type "text/html")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (delete-file qfname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (delete-file dbfname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (error nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (defun url-wais-anytostring (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;; Convert a (:any ....) wais construct back into a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (mapconcat 'char-to-string (car (cdr (memq ':bytes x))) ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (defun url-parse-wais-doc-id (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;; Return a list item that points at the doc-id specified by X
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (let* ((document (car (cdr (memq ':document x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (doc-id (car (cdr (memq ':doc-id document))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (score (car (cdr (memq ':score x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (title (car (cdr (memq ':headline document))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (type (car (cdr (memq ':type document))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (size (car (cdr (memq ':number-of-bytes document))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (server (car (cdr (memq ':original-server doc-id))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (dbase (car (cdr (memq ':original-database doc-id))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (localid (car (cdr (memq ':original-local-id doc-id))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (dist-server (car (cdr (memq ':distributor-server doc-id))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (dist-dbase (car (cdr (memq ':distributor-database doc-id))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (dist-id (car (cdr (memq ':distributor-local-id doc-id))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (copyright (or (car (cdr (memq ':copyright-disposition doc-id))) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (format "<a href=\"wais://%s:%s/%s/%s/%d/1=%s;2=%s;3=%s;4=%s;5=%s;6=%s;7=%d;\">%s (Score = %s)</a>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 url-current-server url-current-port url-current-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 type size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (url-hexify-string (url-wais-anytostring server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (url-hexify-string (url-wais-anytostring dbase))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (url-hexify-string (url-wais-anytostring localid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (url-hexify-string (url-wais-anytostring dist-server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (url-hexify-string (url-wais-anytostring dist-dbase))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (url-hexify-string (url-wais-anytostring dist-id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 copyright title score)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (defun url-grok-wais-href (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 "Return a list of server, port, database, search-term, doc-id"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (if (string-match "wais:/+\\([^/:]+\\):*\\([^/]*\\)/+\\(.*\\)" url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (let ((host (url-match url 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (port (url-match url 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (data (url-match url 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (list host port data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (make-list 3 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (defun url-wais (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;; Retrieve a document via WAIS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (if (and url-wais-gateway-server url-wais-gateway-port)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (url-retrieve
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (format "http://%s:%s/%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 url-wais-gateway-server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 url-wais-gateway-port
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (substring url (match-end 0) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (let ((href (url-grok-wais-href url)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (url-clear-tmp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (setq url-current-type "wais"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 url-current-server (nth 0 href)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 url-current-port (nth 1 href)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 url-current-file (nth 2 href))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ((string-match "2=\\(.*\\);3=\\([^ ;]+\\)" (nth 2 href)); full link
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (url-retrieve-wais-docid (nth 0 href) (nth 1 href)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (url-match (nth 2 href) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (url-match (nth 2 href) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ((string-match "\\([^\\?]+\\)\\?\\(.*\\)" (nth 2 href)) ; stored query
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (url-perform-wais-query (nth 0 href) (nth 1 href)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (url-match (nth 2 href) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (url-match (nth 2 href) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (insert "<title>WAIS search</title>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 "<h1>WAIS search of " (nth 2 href) "</h1>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 "<hr>\n"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
243 (format "<form action=\"%s\" enctype=\"application/x-w3-wais\">\n" url)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 "Enter search term: <input name=\"internal-wais\">\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 "</form>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 "<hr>\n"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (provide 'url-wais)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249