]> code.delx.au - gnu-emacs/blobdiff - lisp/net/ldap.el
Convert consecutive FSF copyright years to ranges.
[gnu-emacs] / lisp / net / ldap.el
index 68afee6a1a21383370bd663cd63ea2d2b72df292..3ccad277ffb48ef3a9330b7612774c1776fb1627 100644 (file)
@@ -1,7 +1,6 @@
 ;;; ldap.el --- client interface to LDAP for Emacs
 
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2011  Free Software Foundation, Inc.
 
 ;; Author: Oscar Figueiredo <oscar@cpe.fr>
 ;; Maintainer: FSF
@@ -43,7 +42,7 @@
   :group 'comm)
 
 (defcustom ldap-default-host nil
-  "*Default LDAP server.
+  "Default LDAP server.
 A TCP port number can be appended to that name using a colon as
 a separator."
   :type '(choice (string :tag "Host name")
@@ -51,14 +50,14 @@ a separator."
   :group 'ldap)
 
 (defcustom ldap-default-port nil
-  "*Default TCP port for LDAP connections.
+  "Default TCP port for LDAP connections.
 Initialized from the LDAP library at build time. Default value is 389."
   :type '(choice (const :tag "Use library default" nil)
                 (integer :tag "Port number"))
   :group 'ldap)
 
 (defcustom ldap-default-base nil
-  "*Default base for LDAP searches.
+  "Default base for LDAP searches.
 This is a string using the syntax of RFC 1779.
 For instance, \"o=ACME, c=US\" limits the search to the
 Acme organization in the United States."
@@ -68,7 +67,7 @@ Acme organization in the United States."
 
 
 (defcustom ldap-host-parameters-alist nil
-  "*Alist of host-specific options for LDAP transactions.
+  "Alist of host-specific options for LDAP transactions.
 The format of each list element is (HOST PROP1 VAL1 PROP2 VAL2 ...).
 HOST is the hostname of an LDAP server (with an optional TCP port number
 appended to it using a colon as a separator).
@@ -148,28 +147,28 @@ Valid properties include:
   :group 'ldap)
 
 (defcustom ldap-ldapsearch-prog "ldapsearch"
-  "*The name of the ldapsearch command line program."
+  "The name of the ldapsearch command line program."
   :type '(string :tag "`ldapsearch' Program")
   :group 'ldap)
 
 (defcustom ldap-ldapsearch-args '("-LL" "-tt")
-  "*A list of additional arguments to pass to `ldapsearch'."
+  "A list of additional arguments to pass to `ldapsearch'."
   :type '(repeat :tag "`ldapsearch' Arguments"
                 (string :tag "Argument"))
   :group 'ldap)
 
 (defcustom ldap-ignore-attribute-codings nil
-  "*If non-nil, do not encode/decode LDAP attribute values."
+  "If non-nil, do not encode/decode LDAP attribute values."
   :type 'boolean
   :group 'ldap)
 
 (defcustom ldap-default-attribute-decoder nil
-  "*Decoder function to use for attributes whose syntax is unknown."
+  "Decoder function to use for attributes whose syntax is unknown."
   :type 'symbol
   :group 'ldap)
 
 (defcustom ldap-coding-system 'utf-8
-  "*Coding system of LDAP string values.
+  "Coding system of LDAP string values.
 LDAP v3 specifies the coding system of strings to be UTF-8."
   :type 'symbol
   :group 'ldap)
@@ -524,8 +523,7 @@ an alist of attribute/value pairs."
            (equal "" filter))
        (error "No search filter"))
     (setq filter (cons filter attributes))
-    (save-excursion
-      (set-buffer buf)
+    (with-current-buffer buf
       (erase-buffer)
       (if (and host
               (not (equal "" host)))
@@ -557,13 +555,10 @@ an alist of attribute/value pairs."
       (if (and sizelimit
               (not (equal "" sizelimit)))
          (setq arglist (nconc arglist (list (format "-z%s" sizelimit)))))
-      (eval `(call-process ldap-ldapsearch-prog
-                          nil
-                          buf
-                          nil
-                          ,@arglist
-                          ,@ldap-ldapsearch-args
-                          ,@filter))
+      (apply #'call-process ldap-ldapsearch-prog
+            ;; Ignore stderr, which can corrupt results
+            nil (list buf nil) nil
+            (append arglist ldap-ldapsearch-args filter))
       (insert "\n")
       (goto-char (point-min))
 
@@ -580,9 +575,7 @@ an alist of attribute/value pairs."
        (while (progn
                 (skip-chars-forward " \t\n")
                 (not (eobp)))
-         (setq dn (buffer-substring (point) (save-excursion
-                                              (end-of-line)
-                                              (point))))
+         (setq dn (buffer-substring (point) (point-at-eol)))
          (forward-line 1)
           (while (looking-at "^\\([A-Za-z][-A-Za-z0-9]*\
 \\|[0-9]+\\(?:\\.[0-9]+\\)*\\)\\(;[-A-Za-z0-9]+\\)*[=:\t ]+\
@@ -597,8 +590,7 @@ an alist of attribute/value pairs."
            ;; Do not try to open non-existent files
            (if (equal value "")
                (setq value " ")
-             (save-excursion
-               (set-buffer bufval)
+             (with-current-buffer bufval
                (erase-buffer)
                (set-buffer-multibyte nil)
                (insert-file-contents-literally value)
@@ -607,9 +599,9 @@ an alist of attribute/value pairs."
            (setq record (cons (list name value)
                               record))
            (forward-line 1))
-         (setq result (cons (if withdn
-                                (cons dn (nreverse record))
-                              (nreverse record)) result))
+         (push (if withdn
+                   (cons dn (nreverse record))
+                 (nreverse record)) result)
          (setq record nil)
          (skip-chars-forward " \t\n")
          (message "Parsing results... %d" numres)
@@ -619,5 +611,4 @@ an alist of attribute/value pairs."
 
 (provide 'ldap)
 
-;; arch-tag: 47913a76-6155-42e6-ac58-6d28b5d50eb0
 ;;; ldap.el ends here