comparison lisp/net/net-utils.el @ 92740:9f968e893cca

(iwconfig-program-options): Doc fix. (net-utils-run-program, run-network-program): Define as functions.
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 11 Mar 2008 10:21:41 +0000
parents 4054054dd212
children 1e3a407766b9
comparison
equal deleted inserted replaced
92739:39c418592dee 92740:9f968e893cca
114 :group 'net-utils 114 :group 'net-utils
115 :type 'string 115 :type 'string
116 :version "23.1") 116 :version "23.1")
117 117
118 (defcustom iwconfig-program-options nil 118 (defcustom iwconfig-program-options nil
119 "Options for `iwconfig-program'." 119 "Options for the iwconfig program."
120 :group 'net-utils 120 :group 'net-utils
121 :type '(repeat string) 121 :type '(repeat string)
122 :version "23.1") 122 :version "23.1")
123 123
124 (define-obsolete-variable-alias 'ipconfig-program-options 124 (define-obsolete-variable-alias 'ipconfig-program-options
310 (insert filtered-string) 310 (insert filtered-string)
311 (set-marker (process-mark process) (point))) 311 (set-marker (process-mark process) (point)))
312 (if moving (goto-char (process-mark process)))) 312 (if moving (goto-char (process-mark process))))
313 (set-buffer old-buffer)))) 313 (set-buffer old-buffer))))
314 314
315 (defmacro net-utils-run-program (name header program &rest args) 315 (defun net-utils-run-program (name header program args)
316 "Run a network information program." 316 "Run a network information program."
317 ` (let ((buf (get-buffer-create (concat "*" ,name "*")))) 317 (let ((buf (get-buffer-create (concat "*" name "*"))))
318 (set-buffer buf) 318 (set-buffer buf)
319 (erase-buffer) 319 (erase-buffer)
320 (insert ,header "\n") 320 (insert header "\n")
321 (set-process-filter 321 (set-process-filter
322 (apply 'start-process ,name buf ,program ,@args) 322 (apply 'start-process name buf program args)
323 'net-utils-remove-ctrl-m-filter) 323 'net-utils-remove-ctrl-m-filter)
324 (display-buffer buf) 324 (display-buffer buf)
325 buf)) 325 buf))
326 326
327 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 327 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
328 ;; Wrappers for external network programs 328 ;; Wrappers for external network programs
329 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 329 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
330 330
614 (cons 'https 443) 614 (cons 'https 443)
615 (cons 'rlogin 513)) 615 (cons 'rlogin 513))
616 "Alist of services and associated TCP port numbers. 616 "Alist of services and associated TCP port numbers.
617 This list is not complete.") 617 This list is not complete.")
618 618
619 ;; Workhorse macro 619 ;; Workhorse routine
620 (defmacro run-network-program (process-name host port 620 (defun run-network-program (process-name host port &optional initial-string)
621 &optional initial-string) 621 (let ((tcp-connection)
622 `(let ((tcp-connection) 622 (buf))
623 (buf)) 623 (setq buf (get-buffer-create (concat "*" process-name "*")))
624 (setq buf (get-buffer-create (concat "*" ,process-name "*")))
625 (set-buffer buf) 624 (set-buffer buf)
626 (or 625 (or
627 (setq tcp-connection 626 (setq tcp-connection
628 (open-network-stream 627 (open-network-stream process-name buf host port))
629 ,process-name 628 (error "Could not open connection to %s" host))
630 buf
631 ,host
632 ,port))
633 (error "Could not open connection to %s" ,host))
634 (erase-buffer) 629 (erase-buffer)
635 (set-marker (process-mark tcp-connection) (point-min)) 630 (set-marker (process-mark tcp-connection) (point-min))
636 (set-process-filter tcp-connection 'net-utils-remove-ctrl-m-filter) 631 (set-process-filter tcp-connection 'net-utils-remove-ctrl-m-filter)
637 (and ,initial-string 632 (and initial-string
638 (process-send-string tcp-connection 633 (process-send-string tcp-connection
639 (concat ,initial-string "\r\n"))) 634 (concat initial-string "\r\n")))
640 (display-buffer buf))) 635 (display-buffer buf)))
641 636
642 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 637 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
643 ;; Simple protocols 638 ;; Simple protocols
644 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 639 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;