Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 35 lines (27 sloc) 1.024 kb
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 <me@dmitrymatveev.co.uk>
;;
;; 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.
Something went wrong with that request. Please try again.