Mercurial > emacs
annotate lisp/url/url-ns.el @ 71356:a183bff9cb83
(mac-text-encoding-ascii): New constant.
(mac-utxt-to-string): Use it.
(mac-ts-update-active-input-area): Use mac-ae-number.
author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
---|---|
date | Fri, 16 Jun 2006 08:07:59 +0000 |
parents | e8a3fb527b77 |
children | e3694f1cb928 d04d8ccb3c41 |
rev | line source |
---|---|
54695 | 1 ;;; url-ns.el --- Various netscape-ish functions for proxy definitions |
57612 | 2 |
68640
e8a3fb527b77
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64748
diff
changeset
|
3 ;; Copyright (C) 1997, 1998, 1999, 2004, 2005, |
e8a3fb527b77
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64748
diff
changeset
|
4 ;; 2006 Free Software Foundation, Inc. |
57612 | 5 |
54695 | 6 ;; Keywords: comm, data, processes, hypermedia |
7 | |
57612 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64084 | 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02110-1301, USA. | |
57612 | 24 |
25 ;;; Code: | |
54695 | 26 |
27 (require 'url-gw) | |
28 | |
29 ;;;###autoload | |
30 (defun isPlainHostName (host) | |
31 (not (string-match "\\." host))) | |
32 | |
33 ;;;###autoload | |
34 (defun dnsDomainIs (host dom) | |
35 (string-match (concat (regexp-quote dom) "$") host)) | |
36 | |
37 ;;;###autoload | |
38 (defun dnsResolve (host) | |
39 (url-gateway-nslookup-host host)) | |
40 | |
41 ;;;###autoload | |
42 (defun isResolvable (host) | |
43 (if (string-match "^[0-9.]+$" host) | |
44 t | |
45 (not (string= host (url-gateway-nslookup-host host))))) | |
46 | |
47 ;;;###autoload | |
48 (defun isInNet (ip net mask) | |
49 (let ((netc (split-string ip "\\.")) | |
50 (ipc (split-string net "\\.")) | |
51 (maskc (split-string mask "\\."))) | |
52 (if (or (/= (length netc) (length ipc)) | |
53 (/= (length ipc) (length maskc))) | |
54 nil | |
62400
e30c08177a3b
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
57612
diff
changeset
|
55 (setq netc (mapcar 'string-to-number netc) |
e30c08177a3b
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
57612
diff
changeset
|
56 ipc (mapcar 'string-to-number ipc) |
e30c08177a3b
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
57612
diff
changeset
|
57 maskc (mapcar 'string-to-number maskc)) |
54695 | 58 (and |
59 (= (logand (nth 0 netc) (nth 0 maskc)) | |
60 (logand (nth 0 ipc) (nth 0 maskc))) | |
61 (= (logand (nth 1 netc) (nth 1 maskc)) | |
62 (logand (nth 1 ipc) (nth 1 maskc))) | |
63 (= (logand (nth 2 netc) (nth 2 maskc)) | |
64 (logand (nth 2 ipc) (nth 2 maskc))) | |
65 (= (logand (nth 3 netc) (nth 3 maskc)) | |
66 (logand (nth 3 ipc) (nth 3 maskc))))))) | |
67 | |
68 ;; Netscape configuration file parsing | |
69 (defvar url-ns-user-prefs nil | |
70 "Internal, do not use.") | |
71 | |
72 ;;;###autoload | |
73 (defun url-ns-prefs (&optional file) | |
74 (if (not file) | |
75 (setq file (expand-file-name "~/.netscape/preferences.js"))) | |
76 (if (not (and (file-exists-p file) | |
77 (file-readable-p file))) | |
78 (message "Could not open %s for reading" file) | |
79 (save-excursion | |
80 (let ((false nil) | |
81 (true t)) | |
82 (setq url-ns-user-prefs (make-hash-table :size 13 :test 'equal)) | |
83 (set-buffer (get-buffer-create " *ns-parse*")) | |
84 (erase-buffer) | |
85 (insert-file-contents file) | |
86 (goto-char (point-min)) | |
87 (while (re-search-forward "^//" nil t) | |
88 (replace-match ";;")) | |
89 (goto-char (point-min)) | |
90 (while (re-search-forward "^user_pref(" nil t) | |
91 (replace-match "(url-ns-set-user-pref ")) | |
92 (goto-char (point-min)) | |
93 (while (re-search-forward "\"," nil t) | |
94 (replace-match "\"")) | |
95 (goto-char (point-min)) | |
96 (eval-buffer))))) | |
97 | |
98 (defun url-ns-set-user-pref (key val) | |
99 (puthash key val url-ns-user-prefs)) | |
100 | |
101 ;;;###autoload | |
102 (defun url-ns-user-pref (key &optional default) | |
103 (gethash key url-ns-user-prefs default)) | |
104 | |
105 (provide 'url-ns) | |
54699 | 106 |
107 ;;; arch-tag: 69520992-cf97-40b4-9ad1-c866d3cae5bf | |
57612 | 108 ;;; url-ns.el ends here |