Mercurial > emacs
comparison lisp/net/socks.el @ 78635:65b448298f0c
(socks-username/password-auth-filter):
Remove unused vars `state' and `desired-len'.
(socks-parse-services, socks-nslookup-host): Use with-current-buffer.
(socks-wait-for-state-change): Use new-style backquotes.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 23 Aug 2007 18:36:07 +0000 |
parents | 84cf1e2214c5 |
children | 6888fd3398e8 92ccd83174e6 |
comparison
equal
deleted
inserted
replaced
78634:933891e04bae | 78635:65b448298f0c |
---|---|
261 (defconst socks-state-authenticated 2) | 261 (defconst socks-state-authenticated 2) |
262 (defconst socks-state-waiting 3) | 262 (defconst socks-state-waiting 3) |
263 (defconst socks-state-connected 4) | 263 (defconst socks-state-connected 4) |
264 | 264 |
265 (defmacro socks-wait-for-state-change (proc htable cur-state) | 265 (defmacro socks-wait-for-state-change (proc htable cur-state) |
266 (` | 266 `(while (and (= (gethash 'state ,htable) ,cur-state) |
267 (while (and (= (gethash 'state (, htable)) (, cur-state)) | 267 (memq (process-status ,proc) '(run open))) |
268 (memq (process-status (, proc)) '(run open))) | 268 (accept-process-output ,proc socks-timeout))) |
269 (accept-process-output (, proc) socks-timeout)))) | |
270 | 269 |
271 (defun socks-filter (proc string) | 270 (defun socks-filter (proc string) |
272 (let ((info (gethash proc socks-connections)) | 271 (let ((info (gethash proc socks-connections)) |
273 state version desired-len) | 272 state version desired-len) |
274 (or info (error "socks-filter called on non-SOCKS connection %S" proc)) | 273 (or info (error "socks-filter called on non-SOCKS connection %S" proc)) |
491 | 490 |
492 (defun socks-parse-services () | 491 (defun socks-parse-services () |
493 (if (not (and (file-exists-p socks-services-file) | 492 (if (not (and (file-exists-p socks-services-file) |
494 (file-readable-p socks-services-file))) | 493 (file-readable-p socks-services-file))) |
495 (error "Could not find services file: %s" socks-services-file)) | 494 (error "Could not find services file: %s" socks-services-file)) |
496 (save-excursion | 495 (clrhash socks-tcp-services) |
497 (clrhash socks-tcp-services) | 496 (clrhash socks-udp-services) |
498 (clrhash socks-udp-services) | 497 (with-current-buffer (get-buffer-create " *socks-tmp*") |
499 (set-buffer (get-buffer-create " *socks-tmp*")) | |
500 (erase-buffer) | 498 (erase-buffer) |
501 (insert-file-contents socks-services-file) | 499 (insert-file-contents socks-services-file) |
502 ;; Nuke comments | 500 ;; Nuke comments |
503 (goto-char (point-min)) | 501 (goto-char (point-min)) |
504 (while (re-search-forward "#.*" nil t) | 502 (while (re-search-forward "#.*" nil t) |
564 'socks-username/password-auth) | 562 'socks-username/password-auth) |
565 | 563 |
566 (defconst socks-username/password-auth-version 1) | 564 (defconst socks-username/password-auth-version 1) |
567 | 565 |
568 (defun socks-username/password-auth-filter (proc str) | 566 (defun socks-username/password-auth-filter (proc str) |
569 (let ((info (gethash proc socks-connections)) | 567 (let ((info (gethash proc socks-connections))) |
570 state desired-len) | |
571 (or info (error "socks-filter called on non-SOCKS connection %S" proc)) | 568 (or info (error "socks-filter called on non-SOCKS connection %S" proc)) |
572 (setq state (gethash 'state info)) | |
573 (puthash 'scratch (concat (gethash 'scratch info) str) info) | 569 (puthash 'scratch (concat (gethash 'scratch info) str) info) |
574 (if (< (length (gethash 'scratch info)) 2) | 570 (if (< (length (gethash 'scratch info)) 2) |
575 nil | 571 nil |
576 (puthash 'password-auth-status (aref (gethash 'scratch info) 1) info) | 572 (puthash 'password-auth-status (aref (gethash 'scratch info) 1) info) |
577 (puthash 'state socks-state-authenticated info)))) | 573 (puthash 'state socks-state-authenticated info)))) |
627 (if socks-nslookup-program | 623 (if socks-nslookup-program |
628 (let ((proc (start-process " *nslookup*" " *nslookup*" | 624 (let ((proc (start-process " *nslookup*" " *nslookup*" |
629 socks-nslookup-program host)) | 625 socks-nslookup-program host)) |
630 (res host)) | 626 (res host)) |
631 (set-process-query-on-exit-flag proc nil) | 627 (set-process-query-on-exit-flag proc nil) |
632 (save-excursion | 628 (with-current-buffer (process-buffer proc) |
633 (set-buffer (process-buffer proc)) | |
634 (while (progn | 629 (while (progn |
635 (accept-process-output proc) | 630 (accept-process-output proc) |
636 (memq (process-status proc) '(run open)))) | 631 (memq (process-status proc) '(run open)))) |
637 (goto-char (point-min)) | 632 (goto-char (point-min)) |
638 (if (re-search-forward "Name:.*\nAddress\\(es\\)?: *\\([0-9.]+\\)$" nil t) | 633 (if (re-search-forward "Name:.*\nAddress\\(es\\)?: *\\([0-9.]+\\)$" nil t) |