view lisp/gnus/hex-util.el @ 66168:28718fa5d988

Moved all remaining images from lisp/toolbar to etc/images, moved lisp/toolbar/tool-bar to lisp and "deleted" lisp/toolbar. The low resolution images were placed in their own directory (low-color). Replaced underscore (_) in filenames with dash (-) per convention * make-dist: Create and populate etc/images/low-color. * admin/FOR-RELEASE (DOCUMENTATION): Removed lisp/toolbar from list since it's gone. Also marked mh-e as done. * lisp/toolbar/attach.*, lisp/toolbar/cancel.*, lisp/toolbar/close.*: * lisp/toolbar/copy.*, lisp/toolbar/cut.*, lisp/toolbar/diropen.*: * lisp/toolbar/exit.*, lisp/toolbar/help.*, lisp/toolbar/home.*: * lisp/toolbar/index.*, lisp/toolbar/info.*, lisp/toolbar/mail.*: * lisp/toolbar/new.*, lisp/toolbar/open.*, lisp/toolbar/paste.*, * * lisp/toolbar/preferences.*, lisp/toolbar/print.*, lisp/toolbar/save.*: * lisp/toolbar/saveas.*, lisp/toolbar/search.*: * lisp/toolbar/search-replace.*: lisp/toolbar/spell.*: * lisp/toolbar/undo.*: Moved to etc/images. * lisp/toolbar/lc-copy.*: Moved to etc/images/low-color/copy.*. * lisp/toolbar/lc-cut.*: Moved to etc/images/low-color/cut.*. * lisp/toolbar/lc-help.*: Moved to etc/images/low-color/help.*. * lisp/toolbar/lc-home.*: Moved to etc/images/low-color/home.*. * lisp/toolbar/lc-index.*: Moved to etc/images/low-color/index.*. * lisp/toolbar/lc-new.*: Moved to etc/images/low-color/new.*. * lisp/toolbar/lc-open.*: Moved to etc/images/low-color/open.*. * lisp/toolbar/lc-paste.*: Moved to etc/images/low-color/paste.*. * lisp/toolbar/lc-preferences.*: Moved to etc/images/low-color/preferences.*. * lisp/toolbar/lc-print.*: Moved to etc/images/low-color/print.*. * lisp/toolbar/lc-save.*: Moved to etc/images/low-color/save.*. * lisp/toolbar/lc-saveas.*: Moved to etc/images/low-color/saveas.*. * lisp/toolbar/lc-search.*: Moved to etc/images/low-color/search.*. * lisp/toolbar/lc-spell.*: Moved to etc/images/low-color/spell.*. * lisp/toolbar/lc-undo.*: Moved to etc/images/low-color/undo.*. To conform with convention, the underscore (_) in the following image names were replaced with dash (-) or (/) as appropriate. * lisp/toolbar/back_arrow.*: Moved to etc/images/back-arrow.*. * lisp/toolbar/fld_open.*: Moved to etc/images/fld-open.*. * lisp/toolbar/fwd_arrow.*: Moved to etc/images/fwd-arrow.*. * lisp/toolbar/jump_to.*: Moved to etc/images/jump-to.*. * lisp/toolbar/left_arrow.*: Moved to etc/images/left-arrow.*. * lisp/toolbar/right_arrow.*: Moved to etc/images/right-arrow.*. * lisp/toolbar/up_arrow.*: Moved to etc/images/up-arrow.*. * lisp/toolbar/lc-back_arrow.*.: Moved to etc/images/low-color/back-arrow.*. * lisp/toolbar/lc-fwd_arrow.*.: Moved to etc/images/low-color/fwd-arrow.*. * lisp/toolbar/lc-jump_to.*: Moved to etc/images/low-color/jump-to.*. * lisp/toolbar/lc-left_arrow.*.: Moved to etc/images/low-color/left-arrow.*. * lisp/toolbar/lc-right_arrow.*.: Moved to etc/images/low-color/right-arrow.*. * lisp/toolbar/lc-up_arrow.*: Moved to etc/images/low-color/up-arrow.*. * lisp/toolbar/mail_compose.*.: Moved to etc/images/mail/compose.*. * lisp/toolbar/mail_send.*: Moved to etc/images/mail/send.*. * lisp/info.el (info-tool-bar-map): Replaced underscores in image names with dashes. * lisp/makefile.w32-in (WINS): Removed toolbar. * lisp/menu-bar.el: Replaced toolbar/tool-bar.el with tool-bar.el in comment. * lisp/tool-bar.el: Moved to lisp from lisp/toolbar. Now that lisp/toolbar is empty, it should be deleted when folks run "cvs up -P". * etc/images/README: Incorporated the content of lisp/toolbar/README now that all of the images are here.
author Bill Wohler <wohler@newt.com>
date Mon, 17 Oct 2005 22:21:06 +0000
parents fafd692d1e40
children 1077b8039c32
line wrap: on
line source

;;; hex-util.el --- Functions to encode/decode hexadecimal string.

;; Copyright (C) 1999, 2001, 2002, 2003, 2004,
;;   2005 Free Software Foundation, Inc.

;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
;; Keywords: data

;; This file is part of FLIM (Faithful Library about Internet Message).

;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;;; Code:

(eval-when-compile
  (defmacro hex-char-to-num (chr)
    (` (let ((chr (, chr)))
	 (cond
	  ((and (<= ?a chr)(<= chr ?f)) (+ (- chr ?a) 10))
	  ((and (<= ?A chr)(<= chr ?F)) (+ (- chr ?A) 10))
	  ((and (<= ?0 chr)(<= chr ?9)) (- chr ?0))
	  (t (error "Invalid hexadecimal digit `%c'" chr))))))
  (defmacro num-to-hex-char (num)
    (` (aref "0123456789abcdef" (, num)))))

(defun decode-hex-string (string)
  "Decode hexadecimal STRING to octet string."
  (let* ((len (length string))
	 (dst (make-string (/ len 2) 0))
	 (idx 0)(pos 0))
    (while (< pos len)
;;; logior and lsh are not byte-coded.
;;;  (aset dst idx (logior (lsh (hex-char-to-num (aref string pos)) 4)
;;; 			    (hex-char-to-num (aref string (1+ pos)))))
      (aset dst idx (+ (* (hex-char-to-num (aref string pos)) 16)
		       (hex-char-to-num (aref string (1+ pos)))))
      (setq idx (1+ idx)
	    pos (+ 2 pos)))
    dst))

(defun encode-hex-string (string)
  "Encode octet STRING to hexadecimal string."
  (let* ((len (length string))
	 (dst (make-string (* len 2) 0))
	 (idx 0)(pos 0))
    (while (< pos len)
;;; logand and lsh are not byte-coded.
;;;  (aset dst idx (num-to-hex-char (logand (lsh (aref string pos) -4) 15)))
      (aset dst idx (num-to-hex-char (/ (aref string pos) 16)))
      (setq idx (1+ idx))
;;;  (aset dst idx (num-to-hex-char (logand (aref string pos) 15)))
      (aset dst idx (num-to-hex-char (% (aref string pos) 16)))
      (setq idx (1+ idx)
	    pos (1+ pos)))
    dst))

(provide 'hex-util)

;;; arch-tag: fe8aaa79-6c86-400e-813f-5a8cc4cb3859
;;; hex-util.el ends here