1 ;;; url-ns.el --- Various netscape-ish functions for proxy definitions
3 ;; Copyright (C) 1997, 1998, 1999, 2004, 2005,
4 ;; 2006, 2007, 2008 Free Software Foundation, Inc.
6 ;; Keywords: comm, data, processes, hypermedia
8 ;; This file is part of GNU Emacs.
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 3, or (at your option)
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.
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
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
30 (defun isPlainHostName (host)
31 (not (string-match "\\." host
)))
34 (defun dnsDomainIs (host dom
)
35 (string-match (concat (regexp-quote dom
) "$") host
))
38 (defun dnsResolve (host)
39 (url-gateway-nslookup-host host
))
42 (defun isResolvable (host)
43 (if (string-match "^[0-9.]+$" host
)
45 (not (string= host
(url-gateway-nslookup-host host
)))))
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
)))
55 (setq netc
(mapcar 'string-to-number netc
)
56 ipc
(mapcar 'string-to-number ipc
)
57 maskc
(mapcar 'string-to-number maskc
))
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
)))))))
68 ;; Netscape configuration file parsing
69 (defvar url-ns-user-prefs nil
70 "Internal, do not use.")
73 (defun url-ns-prefs (&optional 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
)
82 (setq url-ns-user-prefs
(make-hash-table :size
13 :test
'equal
))
83 (set-buffer (get-buffer-create " *ns-parse*"))
85 (insert-file-contents file
)
86 (goto-char (point-min))
87 (while (re-search-forward "^//" nil t
)
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
)
95 (goto-char (point-min))
98 (defun url-ns-set-user-pref (key val
)
99 (puthash key val url-ns-user-prefs
))
102 (defun url-ns-user-pref (key &optional default
)
103 (gethash key url-ns-user-prefs default
))
107 ;;; arch-tag: 69520992-cf97-40b4-9ad1-c866d3cae5bf
108 ;;; url-ns.el ends here