Re: uuencode/uudecode

2000-03-02 Thread Kai Großjohann

Pete Forman [EMAIL PROTECTED] writes:

 If /dev/stdout was available on AIX, IRIX, etc. then we would not need 
 to jump through some of these hoops.

Ah, yes, silly me.  Hm.  But one could do the decoding to a buffer and
then do (princ (buffer-string)) or something like this.

 And can emacs generally read from stdin and write to stdout?

Writing to stdout is surely possible with the print functions when
running in batch mode.  I'm not sure about reading from stdin, though.

kai
-- 
~/.signature: No such file or directory



Re: uuencode/uudecode

2000-03-02 Thread Francesco Potorti`

   emacs -batch -eval '(progn (add-to-list '\''load-path
   "~/lisp/gnus/lisp/") (require '\''uudecode) (find-file "foo.uue")
   (uudecode-decode-region (point-min) (point-max) "/dev/stdout"))'
   2/dev/null

I have elisp functions for  doing coding and decoding that (according to
my tests) were  faster than any other elisp  before mime64 de/coding was
written in C  inside Emacs.  I suppose my code  can trivially be changed
to doing uuencode/decode.  I append it.  If people are interested, I can
change  it myself  and repost  it  after having  benchmarked it  against
gnus'.

===File ~/elisp/mime64.el===
(setq mime64-code-string
  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")

(setq mime64-decode-vector (make-vector 256 nil))
(let ((i 0) (case-fold-search nil))
  (while ( i 256)
(aset mime64-decode-vector i
  (string-match (regexp-quote (char-to-string i)) mime64-code-string))
(setq i (1+ i

(defun mime-code (c)
  (cond
   ((aref mime64-decode-vector c))
   ((char-equal c ?=)
(setq endchars (1+ endchars))
0)
   (nil
(error
 "Character %c does not match Mime base64 coding" c

(defun mime64-decode-region (beg end)
  (interactive "r")
  (barf-if-buffer-read-only)
  (let
  ((exchange (= (point) beg))
   (endchars 0)
   (list) (code))
(goto-char beg)
(while ( (point) end)
  (setq list (mapcar 'mime-code (buffer-substring-no-properties (point) (+ (point) 
4
  (setq code (+ (nth 3 list) (lsh (nth 2 list) 6)
(lsh (nth 1 list) 12) (lsh (car list) 18)))
  (delete-char 4)
  (cond
   ((zerop endchars)
(insert (lsh code -16) (logand 255 (lsh code -8)) (logand 255 code)))
   ((= endchars 1)
(insert (lsh code -16) (logand 255 (lsh code -8)))
(setq end (point)))
   ((= endchars 2)
(insert (lsh code -16))
(setq end (point
  (if (char-equal (following-char) ?\n)
  (progn (delete-char 1)
 (setq end (- end 2)))
(setq end (1- end
(if exchange
(exchange-point-and-mark




Re: uuencode/uudecode

2000-02-29 Thread Daniel Pittman

On 29 Feb 2000, Kai Großjohann [EMAIL PROTECTED]
wrote:

 Pete Forman [EMAIL PROTECTED] writes:
 
 FWIW here is a command that will "uudecode" to stdout on AIX.
 
 sed '/^begin/d;/^[` ]$/d;/^end/d' | iconv -f uucode -t ISO8859-1
 
 Very good!  I have now added this to the documentation for the
 rcp-methods variable.  Thanks Pete!
 
 Hm.  I think I should be adding this to the Info file, too.  Hm.
 Right now, the info file does not contain stuff like this.  Hm.  Maybe
 it would be useful to include a section on adding own methods to the
 info file.

That would seem like a sensible thing to add.

 Daniel,
 
 would you like to write that (with your better English and all) or do
 you want me to write a draft and then you pound on it until it looks
 like real English rather than some sort of mock-up?

I am happy if you want to draft up something, otherwise I will have a
run at it, probably by the end of the weekend. My life is, almost
regrettably, rather busy at present.[1]

Daniel

Footnotes: 
[1]  Almost, because it's all fun that I am having. ;)

-- 
When you stop learning, stop listening, stop looking and asking
questions, always new questions, then it is time to die.
-- Lillian Smith