-
Notifications
You must be signed in to change notification settings - Fork 5
/
shampoo-auth.el
34 lines (27 loc) · 1 KB
/
shampoo-auth.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
;;; shampoo-auth.el --- Shampoo authentication routines
;;
;; Copyright (C) 2010 - 2012 Dmitry Matveev <[email protected]>
;;
;; This software is released under terms of the MIT license,
;; please refer to the LICENSE file for details.
(eval-when-compile (require 'cl))
(require 'shampoo-regexp)
(defstruct shampoo-connect-info
login host port)
(defun shampoo-connect-info-str (info)
(format "%s@%s:%d"
(shampoo-connect-info-login info)
(shampoo-connect-info-host info)
(shampoo-connect-info-port info)))
(defun shampoo-parse-login (str)
(let ((parsed (shampoo-regexp-parse str '(:Wd "@" :Wa ":" :D))))
(when parsed
(make-shampoo-connect-info
:login (shampoo-regexp-extract 0 parsed)
:host (shampoo-regexp-extract 1 parsed)
:port (string-to-number
(shampoo-regexp-extract 2 parsed))))))
(defun shampoo-prepare-pass (magic pass)
(md5 (concat magic (md5 pass))))
(provide 'shampoo-auth)
;;; shampoo-auth.el ends here.