This file is indexed.

/usr/share/emacs/site-lisp/w3m/shimbun/sb-cgi-board.el is in w3m-el 1.4.483+0.20120614-8.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
;;; sb-cgi-board.el --- Shimbun backend for CGI_Board bulletin board systems

;; Author: TSUCHIYA Masatoshi <tsuchiya@namazu.org>
;; Keywords: shimbun

;; This file is a part of shimbun.

;; 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, 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; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;; This is a shimbun backend to browse CGI_Board bulletin board
;; systems, developed by KUROKI Gen <kuroki@math.tohoku.ac.jp>.

;;; Code:

(require 'shimbun)
(eval-when-compile
  (require 'cl)
  ;; `multiple-value-bind' requires the 2nd argument to be multiple-value,
  ;; not a list, in particular for XEmacs 21.5.  `values-list' does it,
  ;; but is a run-time cl function in XEmacs 21.4 and Emacs 21.
  (when (eq 'identity (symbol-function 'values-list))
    (define-compiler-macro values-list (arg)
      arg)))

(defcustom shimbun-cgi-board-group-alist
  '(("support" .
     "http://www.math.tohoku.ac.jp/~kuroki/support/BBS.cgi?b=cgi_board")
    ("kuroki.a" .
     "http://www.math.tohoku.ac.jp/~kuroki/keijiban/BBS.cgi?b=a")
    ("kuroki.b" .
     "http://www.math.tohoku.ac.jp/~kuroki/keijiban/BBS.cgi?b=b")
    ("kuroki.c" .
     "http://www.math.tohoku.ac.jp/~kuroki/keijiban/BBS.cgi?b=c")
    ("kuroki.e" .
     "http://www.math.tohoku.ac.jp/~kuroki/keijiban/BBS.cgi?b=e")
    ("nojiri" .
     "http://njb.virtualave.net/BBS.cgi?b=nmain")
    ("yamagata" .
     "http://ruitomo.com/~hiroo/bbs/BBS.cgi?b=kohobu"))
  "*An alist of CGI_Board bulletin board systems and their URLs."
  :group 'shimbun
  :type '(repeat
	  (cons :format "%v" :indent 4
		(string :tag "Name")
		(string :tag "      URL"))))

(luna-define-class shimbun-cgi-board (shimbun) ())

(luna-define-method shimbun-groups ((shimbun shimbun-cgi-board))
  (mapcar 'car shimbun-cgi-board-group-alist))

(defsubst shimbun-cgi-board-base-url (shimbun)
  (cdr (assoc (shimbun-current-group-internal shimbun)
	      shimbun-cgi-board-group-alist)))

(luna-define-method shimbun-index-url ((shimbun shimbun-cgi-board))
  (concat (shimbun-cgi-board-base-url shimbun) "&old"))

(luna-define-method shimbun-x-face ((shimbun shimbun-cgi-board))
  nil)

(luna-define-method shimbun-get-headers ((shimbun shimbun-cgi-board)
					 &optional range)
  (catch 'found
    (let ((base (shimbun-cgi-board-base-url shimbun))
	  (no-cache t)
	  (headers))
      (dolist (page (shimbun-cgi-board-get-pages range))
	(let (buffer header)
	  (unwind-protect
	      (with-temp-buffer
		(when (shimbun-fetch-url shimbun
					 (shimbun-expand-url page base)
					 no-cache)
		  (goto-char (point-min))
		  (while (re-search-forward
			  "\n<!--\\([^: \t\r\f\n]+\\):--><hr noshade>\n" nil t)
		    (let* ((fragment (match-string 1))
			   (id (shimbun-cgi-board-make-message-id base
								  fragment)))
		      (when (shimbun-search-id shimbun id)
			(throw 'found headers))
		      (unless buffer
			(with-current-buffer
			    (setq buffer (generate-new-buffer " *temp*"))
			  (shimbun-fetch-url shimbun
					     (concat base "&thread&_f=" page))))
		      (when (setq header
				  (with-current-buffer buffer
				    (shimbun-cgi-board-extract-header base
								      fragment)))
			(push header headers))))))
	    (when buffer
	      (kill-buffer buffer))))
	(setq no-cache nil))
      headers)))

(defconst shimbun-cgi-board-thread-regexp "\\( *\\)\\[\\([^]]+\\)\\] *\
<a name=\"\\([^\"]+\\)\" href=\"\\([^\"]+\\)\" target=\"article\">\\([^<]*\\)\
</a> *<small>(\\(.+\\))</small>")

(defun shimbun-cgi-board-extract-header (base fragment)
  (let (header)
    (goto-char (point-min))
    (while (and (not header) (search-forward fragment nil t))
      (forward-line 0)
      (if (and (looking-at shimbun-cgi-board-thread-regexp)
	       (equal fragment (match-string 3)))
	  (let ((level (length (match-string 1)))
		(url (shimbun-expand-url (match-string 4) base)))
	    (setq header
		  (shimbun-create-header
		   0
		   (let ((subject (match-string 5)))
		     (if (equal subject fragment) "" subject))
		   (match-string 2)
		   (shimbun-cgi-board-make-date-string (match-string 6))
		   (shimbun-cgi-board-make-message-id base (match-string 3))
		   nil nil nil url))
	    (when (> level 0)
	      ;; Search a parent article.
	      (while (and (not (shimbun-header-references header))
			  (zerop (forward-line 1))
			  (not (looking-at "^$")))
		(when (and (looking-at shimbun-cgi-board-thread-regexp)
			   (< (length (match-string 1)) level))
		  (shimbun-header-set-references
		   header
		   (shimbun-cgi-board-make-message-id base
						      (match-string 3)))))))
	(forward-line 1)))
    header))

(defun shimbun-cgi-board-make-date-string (string)
  (save-match-data
    (if (string-match
	 "\\`\\([0-9]+\\)/\\([0-9]+\\)/\\([0-9]+\\) \\([0-9:]+\\)\\'" string)
	(shimbun-make-date-string (string-to-number (match-string 1 string))
				  (string-to-number (match-string 2 string))
				  (string-to-number (match-string 3 string))
				  (match-string 4 string))
      (multiple-value-bind (sec min hour day month year dow dst zone)
	  (values-list (decode-time (shimbun-time-parse-string string)))
	(setq zone (/ zone 60))
	(shimbun-make-date-string year month day
				  (format "%02d:%02d" hour min)
				  (format "%s%02d%02d"
					  (if (>= zone 0) "+" "-")
					  (/ zone 60)
					  (% zone 60)))))))

(defun shimbun-cgi-board-get-pages (&optional range)
  "Return a list of splited index pages."
  (let ((pages)
	(count 0)
	(limit (shimbun-header-index-pages range)))
    (goto-char (point-min))
    (while (and (or (not limit) (<= (incf count) limit))
		(re-search-forward
		 "<a href=\"\\./\\([^.]+\\.html\\)\" target=\"article\">"
		 nil t))
      (push (match-string 1) pages))
    (nreverse pages)))

(defun shimbun-cgi-board-make-message-id (url &optional fragment)
  (save-match-data
    (format "<%s@%s>"
	    (or fragment
		(progn
		  (string-match "\\`[^#]*#" url)
		  (substring url (match-end 0))))
	    (progn
	      (string-match "\\`[^:/#?]+://\\([^/#?]+\\)/" url)
	      (match-string 1 url)))))

(luna-define-method shimbun-clear-contents ((shimbun shimbun-cgi-board) header)
  (let ((id (shimbun-header-id header)))
    (when (string-match "\\`<\\([^@]+\\)@" id)
      (goto-char (point-min))
      (let (start)
	(when (and (search-forward
		    (concat "\n<!--" (match-string 1 id) ":-->") nil t)
		   (setq start (match-end 0))
		   (re-search-forward "<!--[^-]*-->\n" nil t))
	  (delete-region (match-beginning 0) (point-max))
	  (delete-region (point-min) start)
	  (goto-char (point-min))
	  (when (looking-at "<hr[^>]*>")
	    (delete-region (match-beginning 0) (match-end 0)))
	  t)))))

(provide 'sb-cgi-board)

;;; sb-cgi-board.el ends here