1 ;;; url-ns.el --- Various netscape-ish functions for proxy definitions
3 ;; Copyright (C) 1997, 1998, 1999, 2004, 2005 Free Software Foundation, Inc.
5 ;; Keywords: comm, data, processes, hypermedia
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
29 (defun isPlainHostName (host)
30 (not (string-match "\\." host
)))
33 (defun dnsDomainIs (host dom
)
34 (string-match (concat (regexp-quote dom
) "$") host
))
37 (defun dnsResolve (host)
38 (url-gateway-nslookup-host host
))
41 (defun isResolvable (host)
42 (if (string-match "^[0-9.]+$" host
)
44 (not (string= host
(url-gateway-nslookup-host host
)))))
47 (defun isInNet (ip net mask
)
48 (let ((netc (split-string ip
"\\."))
49 (ipc (split-string net
"\\."))
50 (maskc (split-string mask
"\\.")))
51 (if (or (/= (length netc
) (length ipc
))
52 (/= (length ipc
) (length maskc
)))
54 (setq netc
(mapcar 'string-to-number netc
)
55 ipc
(mapcar 'string-to-number ipc
)
56 maskc
(mapcar 'string-to-number maskc
))
58 (= (logand (nth 0 netc
) (nth 0 maskc
))
59 (logand (nth 0 ipc
) (nth 0 maskc
)))
60 (= (logand (nth 1 netc
) (nth 1 maskc
))
61 (logand (nth 1 ipc
) (nth 1 maskc
)))
62 (= (logand (nth 2 netc
) (nth 2 maskc
))
63 (logand (nth 2 ipc
) (nth 2 maskc
)))
64 (= (logand (nth 3 netc
) (nth 3 maskc
))
65 (logand (nth 3 ipc
) (nth 3 maskc
)))))))
67 ;; Netscape configuration file parsing
68 (defvar url-ns-user-prefs nil
69 "Internal, do not use.")
72 (defun url-ns-prefs (&optional file
)
74 (setq file
(expand-file-name "~/.netscape/preferences.js")))
75 (if (not (and (file-exists-p file
)
76 (file-readable-p file
)))
77 (message "Could not open %s for reading" file
)
81 (setq url-ns-user-prefs
(make-hash-table :size
13 :test
'equal
))
82 (set-buffer (get-buffer-create " *ns-parse*"))
84 (insert-file-contents file
)
85 (goto-char (point-min))
86 (while (re-search-forward "^//" nil t
)
88 (goto-char (point-min))
89 (while (re-search-forward "^user_pref(" nil t
)
90 (replace-match "(url-ns-set-user-pref "))
91 (goto-char (point-min))
92 (while (re-search-forward "\"," nil t
)
94 (goto-char (point-min))
97 (defun url-ns-set-user-pref (key val
)
98 (puthash key val url-ns-user-prefs
))
101 (defun url-ns-user-pref (key &optional default
)
102 (gethash key url-ns-user-prefs default
))
106 ;;; arch-tag: 69520992-cf97-40b4-9ad1-c866d3cae5bf
107 ;;; url-ns.el ends here