1 ;;; lj-util.el --- misc elisp utilities for ljupdate
3 ;; Copyright (C) 2002, 2003, 2004, 2005 Edward O'Connor <ted@oconnor.cx>
5 ;; Author: Edward O'Connor <ted@oconnor.cx>
6 ;; Keywords: convenience
8 ;; This file is part of ljupdate, a LiveJournal client for Emacs.
10 ;; ljupdate is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or
13 ;; {at your option} any later version.
15 ;; ljupdate is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING, or type `C-h C-c'. If
22 ;; not, write to the Free Software Foundation at this address:
24 ;; Free Software Foundation
25 ;; 51 Franklin Street, Fifth Floor
26 ;; Boston, MA 02110-1301
41 (defun lj-md5 (string)
42 "MD5s STRING and downcases the result.
43 The LiveJournal server code doesn't accept upcased MD5sums. Case
45 (downcase (md5 string nil nil lj-coding-system
)))
47 (defun lj-number (thing)
48 "Convert THING to a number, if necessary."
49 (cond ((numberp thing
) thing
)
50 ((stringp thing
) (string-to-number thing
))
54 "Return a string representation of 2^N for 0 <= N <= 30."
55 (cond ((or (< n
0) (> n
30))
56 (signal 'args-out-of-range n
))
57 ((< n
27) (number-to-string (lsh 1 n
)))
58 ;; Emacs integers aren't 32-bit quantities, so we cheat.
59 ((= n
27) "134217728")
60 ((= n
28) "268435456")
61 ((= n
29) "536870912")
62 ((= n
30) "1073741824")))
66 ;;; lj-util.el ends here