1 ;;; liece-q-ccl.el --- CTCP binary data quotation in CCL.
2 ;; Copyright (C) 1998-2000 Daiki Ueno
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
7 ;; Keywords: IRC, liece, CTCP
9 ;; This file is part of Liece.
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
34 (require 'poem) ;char-int
37 (defconst liece-quote-ccl-256-table
41 (setq table (nconc table (list i))
45 (broken-facility ccl-cascading-write
46 "Emacs CCL write command does not accept more than 2 arguments."
49 (define-ccl-program cascading-read-test
55 (define-ccl-program liece-quote-ccl-decode
75 (if-broken ccl-cascading-write
79 liece-quote-ccl-256-table))))
83 (define-ccl-program liece-quote-ccl-encode
91 ((= r0 (char-int ?\\))
92 `(write-repeat "\\\\"))
93 ((= r0 (char-int ?\x01))
94 `(write-repeat "\\a"))
95 ((= r0 (char-int ?\n))
96 `(write-repeat "\\n"))
97 ((= r0 (char-int ?\r))
98 `(write-repeat "\\r"))
100 `(write-repeat r0))))
101 liece-quote-ccl-256-table)))))
103 (make-ccl-coding-system
104 'liece-quote-ccl-cs ?Q "CTCP Quote Decoder/Encoder"
105 'liece-quote-ccl-decode 'liece-quote-ccl-encode)
107 (defun liece-quote-ccl-decode-string (string-to-decode)
108 (decode-coding-string string-to-decode 'liece-quote-ccl-cs))
110 (defun liece-quote-ccl-encode-string (string-to-encode)
111 (encode-coding-string string-to-encode 'liece-quote-ccl-cs))
113 (defun liece-quote-ccl-decode-region (min max)
114 (decode-coding-region min max 'liece-quote-ccl-cs))
116 (defun liece-quote-ccl-encode-region (min max)
117 (encode-coding-region min max 'liece-quote-ccl-cs))
119 (defalias 'liece-quote-decode-string 'liece-quote-ccl-decode-string)
120 (defalias 'liece-quote-encode-string 'liece-quote-ccl-encode-string)
122 (defalias 'liece-quote-decode-region 'liece-quote-ccl-decode-region)
123 (defalias 'liece-quote-encode-region 'liece-quote-ccl-encode-region)
125 (provide 'liece-q-ccl)
127 ;;; liece-q-ccl.el ends here