branch: elpa/vm
commit ea1b741392452d01ec8f9cfae34c9d0c85c3e1fd
Merge: a269ad685f e8835dbbbc
Author: Mark Diekhans <ma...@ucsc.edu>
Commit: Mark Diekhans <ma...@ucsc.edu>
Merge branch 'remove-qp-uu' into 'main'
Use Emacs's facilities for base64/qp/uu
See merge request emacs-vm/vm!24
---
Makefile.in | 2 +-
configure.ac | 2 +-
info/vm.texinfo | 25 +------
lisp/vm-folder.el | 8 +-
lisp/vm-mime.el | 211 +++++++---------------------------------------------
lisp/vm-summary.el | 12 +--
lisp/vm-vars.el | 90 +---------------------
src/Makefile.in | 43 -----------
src/base64-decode.c | 77 -------------------
src/base64-encode.c | 76 -------------------
src/qp-decode.c | 104 --------------------------
src/qp-encode.c | 83 ---------------------
12 files changed, 38 insertions(+), 695 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index ac8d7a2542..04861e0c90 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -15,7 +15,7 @@ srcdir = @srcdir@
datarootdir = @datarootdir@
docdir = @docdir@
-SUBDIRS = lisp info src pixmaps
+SUBDIRS = lisp info pixmaps
# the list of source (documentation) files
SOURCES = NEWS
diff --git a/configure.ac b/configure.ac
index 1d5955ddfd..1afbfed296 100644
--- a/configure.ac
+++ b/configure.ac
@@ -244,7 +244,7 @@ AC_INIT([VM],[8.3.x],[viewmail-i...@nongnu.org])
AC_COPYRIGHT([Copyright (C) 2009-2010 VM Development Team
<v...@lists.launchpad.net>])
AC_CONFIG_SRCDIR([configure.ac])
-AC_CONFIG_FILES([Makefile lisp/Makefile info/Makefile src/Makefile
pixmaps/Makefile vm-load.el])
+AC_CONFIG_FILES([Makefile lisp/Makefile info/Makefile pixmaps/Makefile
vm-load.el])
# Common system utilities checking:
AC_PROG_MAKE_SET
diff --git a/info/vm.texinfo b/info/vm.texinfo
index af3288f473..63434896a8 100644
--- a/info/vm.texinfo
+++ b/info/vm.texinfo
@@ -1979,16 +1979,6 @@ can be turned off by setting the variable
@code{vm-display-using-mime} to
@code{nil} and VM will then display @acronym{MIME} messages as plain text
messages.
-@vindex vm-mime-base64-decoder-program
-@vindex vm-mime-base64-encoder-program
-@vindex vm-mime-base64-decoder-switches
-@vindex vm-mime-base64-encoder-switches
-@vindex vm-mime-qp-decoder-program
-@vindex vm-mime-qp-decoder-switches
-@vindex vm-mime-qp-encoder-program
-@vindex vm-mime-qp-encoder-switches
-@vindex vm-mime-uuencode-decoder-program
-@vindex vm-mime-uuencode-decoder-switches
At its most basic level, @acronym{MIME} is a set of transfer encodings used
to ensure error free transport, and a set of content types. VM understands
the two standard @acronym{MIME} transport encodings, @dfn{Quoted-Printable}
@@ -1996,20 +1986,7 @@ and @dfn{BASE64}, and will decode messages that use them
as necessary. VM
will also try to recognize and decode messages using the UNIX @dfn{uuencode}
encoding system. While this is not an official @acronym{MIME} transfer
encoding and never will be, enough old mailers still use it that it is
-worthwhile to attempt to decode it. VM has Emacs-Lisp based
-Quoted-Printable and BASE64 encoders and decoders, but you can have VM use
-external programs to perform these tasks and the process will almost
-certainly be faster. The variables @code{vm-mime-qp-decoder-program},
-@code{vm-mime-qp-decoder-switches}, @code{vm-mime-qp-encoder-program},
-@code{vm-mime-qp-encoder-switches}, @code{vm-mime-base64-decoder-switches},
-@code{vm-mime-base64-encoder-switches},
-@code{vm-mime-base64-decoder-program},
-@code{vm-mime-base64-encoder-program}, tell VM which programs to use and
-what command line switches to pass to them. There are C programs included
-in the VM distribution to handle BASE64 and Quoted-Printable. VM does not
-have a built-in ``uuencode'' decoder, so
-@code{vm-mime-uuencode-decoder-program} must be set non-@code{nil} for VM to
-decode uuencoded @acronym{MIME} objects.
+worthwhile to attempt to decode it.
@menu
* Viewing @acronym{MIME}:: Decoding @acronym{MIME} for viewing
diff --git a/lisp/vm-folder.el b/lisp/vm-folder.el
index a85e40e76f..43bf63b9ef 100644
--- a/lisp/vm-folder.el
+++ b/lisp/vm-folder.el
@@ -2128,8 +2128,6 @@ FOR-OTHER-FOLDER indicates <someting unknown>. USR
2010-03-06"
(save-restriction
(widen)
(let ((old-buffer-modified-p (buffer-modified-p))
- (vm-mime-qp-encoder-program nil) ; use internal code
- (vm-mime-base64-encoder-program nil) ; for speed
(case-fold-search t)
(buffer-read-only nil)
;; don't truncate the printing of large Lisp objects
@@ -2240,8 +2238,6 @@ pending input. So, presumably this is non-interactive.
USR 2012-12-22"
(save-restriction
(widen)
(let ((old-buffer-modified-p (buffer-modified-p))
- (vm-mime-qp-encoder-program nil) ; use internal code
- (vm-mime-base64-encoder-program nil) ; for speed
(case-fold-search t)
(buffer-read-only nil)
;; don't truncate the printing of large Lisp objects
@@ -2254,8 +2250,8 @@ pending input. So, presumably this is non-interactive.
USR 2012-12-22"
(buffer-file-name nil))
(unwind-protect
(while (and mp
- (or (not abort-if-input-pending)
- (not (input-pending-p))))
+ (not (and abort-if-input-pending
+ (input-pending-p))))
(vm-stuff-message-data-internal (car mp))
(setq n (1+ n))
(setq p-last p
diff --git a/lisp/vm-mime.el b/lisp/vm-mime.el
index 1ad6dec07f..9204693303 100644
--- a/lisp/vm-mime.el
+++ b/lisp/vm-mime.el
@@ -425,7 +425,7 @@ freshly parsing the message contents."
(interactive "r")
(let ((buffer-read-only nil))
(subst-char-in-region start end ?_ (string-to-char " ") t)
- (vm-mime-qp-decode-region start end)))
+ (quoted-printable-decode-region start end)))
(fset 'vm-mime-B-decode-region 'vm-mime-base64-decode-region)
@@ -563,7 +563,7 @@ out includes base-64, quoted-printable, uuencode and CRLF
conversion."
(vm-mime-base64-decode-region start end crlf))
((string-match "^quoted-printable$"
(vm-mm-layout-encoding layout))
- (vm-mime-qp-decode-region start end))
+ (quoted-printable-decode-region start end))
((string-match "^x-uue$\\|^x-uuencode$"
(vm-mm-layout-encoding layout))
(vm-mime-uuencode-decode-region start end crlf)))))
@@ -607,180 +607,31 @@ out includes base-64, quoted-printable, uuencode and
CRLF conversion."
(vm-inform 7 "Encoding base64... done"))
(- end start))))
-;; FIXME: Use `quoted-printable-decode-region'!
-(defun vm-mime-qp-decode-region (start end)
- (and (> (- end start) 10000)
- (vm-emit-mime-decoding-message "Decoding quoted-printable..."))
- (let ((work-buffer nil)
- (buf (current-buffer))
- (case-fold-search nil)
- (hex-digit-alist '((?0 . 0) (?1 . 1) (?2 . 2) (?3 . 3)
- (?4 . 4) (?5 . 5) (?6 . 6) (?7 . 7)
- (?8 . 8) (?9 . 9) (?A . 10) (?B . 11)
- (?C . 12) (?D . 13) (?E . 14) (?F . 15)
- ;; some mailer uses lower-case hex
- ;; digits despite this being forbidden
- ;; by the MIME spec.
- (?a . 10) (?b . 11) (?c . 12) (?d . 13)
- (?e . 14) (?f . 15)))
- inputpos stop-point copy-point)
- (unwind-protect
- (save-excursion
- (setq work-buffer (vm-make-work-buffer))
- (if vm-mime-qp-decoder-program
- (let* ((binary-process-output t) ; any text already has CRLFs
- ;; use binary coding system in FSF Emacs/MULE
- (coding-system-for-read (vm-binary-coding-system))
- (coding-system-for-write (vm-binary-coding-system))
- (status (apply 'vm-run-command-on-region
- start end work-buffer
- vm-mime-qp-decoder-program
- vm-mime-qp-decoder-switches)))
- (if (not (eq status t))
- (vm-mime-error "qp-decode failed: %s" (cdr status))))
- (goto-char start)
- (setq inputpos start)
- (while (< inputpos end)
- (skip-chars-forward "^=\n" end)
- (setq stop-point (point))
- (cond ((looking-at "\n")
- ;; spaces or tabs before a hard line break must be ignored
- (skip-chars-backward " \t")
- (setq copy-point (point))
- (goto-char stop-point))
- (t (setq copy-point stop-point)))
- (with-current-buffer work-buffer
- (insert-buffer-substring buf inputpos copy-point))
- (cond ((= (point) end) t)
- ((looking-at "\n")
- (vm-insert-char ?\n 1 nil work-buffer)
- (forward-char))
- (t;; looking at =
- (forward-char)
- ;; a-f because some mailers use lower case hex
- ;; digits despite them being forbidden by the
- ;; MIME spec.
- (cond ((looking-at "[0-9A-Fa-f][0-9A-Fa-f]")
- (vm-insert-char (+ (* (cdr (assq (char-after
(point))
- hex-digit-alist))
- 16)
- (cdr (assq (char-after
- (1+ (point)))
- hex-digit-alist)))
- 1 nil work-buffer)
- (forward-char 2))
- ((looking-at "\n") ; soft line break
- (forward-char))
- ((looking-at "\r")
- ;; assume the user's goatloving
- ;; delivery software didn't convert
- ;; from Internet's CRLF newline
- ;; convention to the local LF
- ;; convention.
- (forward-char))
- ((looking-at "[ \t]")
- ;; garbage added in transit
- (skip-chars-forward " \t" end))
- (t (vm-mime-error "something other than line break
or hex digits after = in quoted-printable encoding")))))
- (setq inputpos (point))))
- (or (markerp end) (setq end (vm-marker end)))
- (goto-char start)
- (insert-buffer-substring work-buffer)
- (delete-region (point) end))
- (and work-buffer (kill-buffer work-buffer))))
- (and (> (- end start) 10000)
- (vm-emit-mime-decoding-message "Decoding quoted-printable... done")))
+(define-obsolete-function-alias 'vm-mime-qp-decode-region
+ #'quoted-printable-decode-region "2024")
;; FIXME: Use `quoted-printable-encode-region'!
(defun vm-mime-qp-encode-region (start end &optional Q-encoding quote-from)
(and (> (- end start) 200)
(vm-inform 7 "Encoding quoted-printable..."))
- (let ((work-buffer nil)
- ;; (buf (current-buffer))
- (cols 0)
- (hex-digit-alist '((?0 . 0) (?1 . 1) (?2 . 2) (?3 . 3)
- (?4 . 4) (?5 . 5) (?6 . 6) (?7 . 7)
- (?8 . 8) (?9 . 9) (?A . 10) (?B . 11)
- (?C . 12) (?D . 13) (?E . 14) (?F . 15)))
- char inputpos)
-
- (unwind-protect
- (save-excursion
- (setq work-buffer (vm-make-work-buffer))
- (if vm-mime-qp-encoder-program
- (let* ((binary-process-output t) ; any text already has CRLFs
- ;; use binary coding system in FSF Emacs/MULE
- (coding-system-for-read (vm-binary-coding-system))
- (coding-system-for-write (vm-binary-coding-system))
- (status (apply 'vm-run-command-on-region
- start end work-buffer
- vm-mime-qp-encoder-program
- vm-mime-qp-encoder-switches)))
- (if (not (eq status t))
- (vm-mime-error "qp-encode failed: %s" (cdr status)))
- (if quote-from
- (with-current-buffer work-buffer
- (goto-char (point-min))
- (while (re-search-forward "^From " nil t)
- (replace-match "=46rom " t t))))
- (if Q-encoding
- (with-current-buffer work-buffer
- ;; strip out the line breaks
- (goto-char (point-min))
- (while (search-forward "=\n" nil t)
- (delete-char -2))
- ;; strip out the soft line breaks
- (goto-char (point-min))
- (while (search-forward "\n" nil t)
- (delete-char -1)))))
- (setq inputpos start)
- (while (< inputpos end)
- (setq char (char-after inputpos))
- (cond ((= char ?\n)
- (vm-insert-char char 1 nil work-buffer)
- (setq cols 0))
- ((and (= char 32)
- (not (= (1+ inputpos) end))
- (not (= ?\n (char-after (1+ inputpos)))))
- (vm-insert-char char 1 nil work-buffer)
- (vm-increment cols))
- ((or (< char 33) (> char 126)
- ;; =
- (= char 61)
- ;; ?
- (and Q-encoding (= char 63))
- ;; _
- (and Q-encoding (= char 95))
- (and quote-from (= cols 0)
- (let ((case-fold-search nil))
- (looking-at "From ")))
- (and (= cols 0) (= char ?.)
- (looking-at "\\.\\(\n\\|\\'\\)")))
- (vm-insert-char ?= 1 nil work-buffer)
- (vm-insert-char (car (rassq (ash (logand char 255) -4)
- hex-digit-alist))
- 1 nil work-buffer)
- (vm-insert-char (car (rassq (logand char 15)
- hex-digit-alist))
- 1 nil work-buffer)
- (setq cols (+ cols 3)))
- (t (vm-insert-char char 1 nil work-buffer)
- (vm-increment cols)))
- (cond ((> cols 70)
- (setq cols 0)
- (if Q-encoding
- nil
- (vm-insert-char ?= 1 nil work-buffer)
- (vm-insert-char ?\n 1 nil work-buffer))))
- (vm-increment inputpos)))
- (or (markerp end) (setq end (vm-marker end)))
- (goto-char start)
- (insert-buffer-substring work-buffer)
- (delete-region (point) end)
- (and (> (- end start) 200)
- (vm-inform 7 "Encoding quoted-printable... done"))
- (- end start))
- (and work-buffer (kill-buffer work-buffer)))))
+ (setq end (copy-marker end t))
+ (save-excursion
+ (require 'qp) ;; `quoted-printable-encode-region' is not autoloaded :-(
+ (declare-function quoted-printable-encode-region "qp")
+ (defvar mm-use-ultra-safe-encoding)
+ (let ((mm-use-ultra-safe-encoding (if quote-from t nil)))
+ (quoted-printable-encode-region start end))
+ (when Q-encoding
+ (goto-char start)
+ (while (search-forward "=\n" end t)
+ (delete-char -2))
+ ;; strip out the soft line breaks
+ (goto-char start)
+ (while (search-forward "\n" end t)
+ (delete-char -1)))
+ (and (> (- end start) 200)
+ (vm-inform 7 "Encoding quoted-printable... done"))
+ (- end start)))
(defun vm-mime-uuencode-decode-region (start end &optional crlf)
(vm-emit-mime-decoding-message "Decoding uuencoded stuff...")
@@ -809,20 +660,7 @@ out includes base-64, quoted-printable, uuencode and CRLF
conversion."
(progn
(goto-char (point-max))
(insert "\n")))
- (if (stringp vm-mime-uuencode-decoder-program)
- (let* ((binary-process-output t) ; any text already has CRLFs
- ;; use binary coding system in FSF Emacs/MULE
- (coding-system-for-read (vm-binary-coding-system))
- (coding-system-for-write (vm-binary-coding-system))
- (status (apply 'vm-run-command-on-region
- (point-min) (point-max) nil
- vm-mime-uuencode-decoder-program
- vm-mime-uuencode-decoder-switches)))
- (if (not (eq status t))
- (vm-mime-error "uuencode failed: %s" (cdr status))))
- (vm-mime-error "no uuencode decoder program defined"))
- (delete-region (point-min) (point-max))
- (insert-file-contents-literally tempfile)
+ (uudecode-decode-region (point-min) (point-max))
(and crlf
(vm-mime-crlf-to-lf-region (point-min) (point-max)))
(set-buffer region-buffer)
@@ -6360,7 +6198,8 @@ should be included (?) USR,
2011-03-27"
(vm-mime-base64-encode-region beg end crlf)
(setq encoding "base64"))
((and (not armor-from) (not armor-dot)
- (string-match "^7bit$" encoding)) t)
+ (string-match "^7bit$" encoding))
+ t)
((string-match "^base64$" encoding) t)
((string-match "^quoted-printable$" encoding) t)
((eq vm-mime-8bit-text-transfer-encoding 'quoted-printable)
diff --git a/lisp/vm-summary.el b/lisp/vm-summary.el
index bd43ce706c..4af9b4943f 100644
--- a/lisp/vm-summary.el
+++ b/lisp/vm-summary.el
@@ -721,9 +721,7 @@ Otherwise, it is a string in mime-decoded form with
text-properties.
(setq match (assoc format (symbol-value alist-var))))
;; The local variable name `vm-su-message' is mandatory here for
;; the format s-expression to work.
- (let ((vm-su-message message)
- (vm-mime-qp-decoder-program nil) ; speed up decoding
- (vm-mime-base64-decoder-program nil))
+ (let ((vm-su-message message))
(if (or tokenize (null vm-display-using-mime))
(eval (cdr match))
(vm-decode-mime-encoded-words-in-string (eval (cdr match)))))))
@@ -760,11 +758,9 @@ tokenized summary TOKENS."
(while tokens
(setq token (car tokens))
(cond ((stringp token)
- (if vm-display-using-mime
- (let ((vm-mime-qp-decoder-program nil) ; speed up decoding
- (vm-mime-base64-decoder-program nil))
- (insert (vm-decode-mime-encoded-words-in-string token)))
- (insert token)))
+ (insert (if vm-display-using-mime
+ (vm-decode-mime-encoded-words-in-string token)
+ token)))
((eq token 'group-begin)
(setq group-list (cons (list (point) (nth 1 tokens)
(nth 2 tokens))
diff --git a/lisp/vm-vars.el b/lisp/vm-vars.el
index 7a7d152b09..4f987646a3 100644
--- a/lisp/vm-vars.el
+++ b/lisp/vm-vars.el
@@ -2495,93 +2495,11 @@ non-nil may let your mail get through."
:group 'vm-mime
:type 'boolean)
-(defcustom vm-mime-base64-decoder-program
- (vm-locate-executable-file "base64-decode")
- "*Non-nil value should be a string that names a MIME base64 decoder.
-If the program is in your executable search path, you need not
-specify a full pathname. The program should expect to read
-base64 data on its standard input and write the converted data
-to its standard output."
- :group 'vm-helpers
- :type '(choice (const :tag "None" nil)
- file))
-
-(defcustom vm-mime-base64-decoder-switches nil
- "*List of command line flags passed to the command named by
-`vm-mime-base64-decoder-program'."
- :group 'vm-helpers
- :type '(choice (const :tag "None" nil)
- (repeat string)))
-
-(defcustom vm-mime-base64-encoder-program
- (vm-locate-executable-file "base64-encode")
- "*Non-nil value should be a string that names a MIME base64 encoder.
-If the program is in your executable search path, you need not
-specify a full pathname. The program should expect arbitrary
-data on its standard input and write base64 data to its standard
-output."
- :group 'vm-helpers
- :type '(choice (const :tag "None" nil)
- file))
-
-(defcustom vm-mime-base64-encoder-switches nil
- "*List of command line flags passed to the command named by
-`vm-mime-base64-encoder-program'."
- :group 'vm-helpers
- :type '(choice (const :tag "None" nil)
- (repeat string)))
+(define-obsolete-variable-alias 'vm-mime-uuencode-decoder-program
+ 'uudecode-decoder-program "2024")
-(defcustom vm-mime-qp-decoder-program (vm-locate-executable-file "qp-decode")
- "*Non-nil value should be a string that names a MIME quoted-printable
-decoder. If the program is in your executable search path, you
-need not specify a full pathname. The program should expect to
-read quoted-printable data on its standard input and write the
-converted data to its standard output."
- :group 'vm-helpers
- :type '(choice (const :tag "None" nil)
- file))
-
-(defcustom vm-mime-qp-decoder-switches nil
- "*List of command line flags passed to the command named by
-`vm-mime-qp-decoder-program'."
- :group 'vm-helpers
- :type '(choice (const :tag "None" nil)
- (repeat string)))
-
-(defcustom vm-mime-qp-encoder-program (vm-locate-executable-file "qp-encode")
- "*Non-nil value should be a string that names a MIME quoted-printable
-encoder. If the program is in your executable search path, you
-need not specify a full pathname. The program should expect
-arbitrary data on its standard input and write quoted-printable
-data to its standard output."
- :group 'vm-helpers
- :type '(choice (const :tag "None" nil)
- file))
-
-(defcustom vm-mime-qp-encoder-switches nil
- "*List of command line flags passed to the command named by
-`vm-mime-qp-encoder-program'."
- :group 'vm-helpers
- :type '(choice (const :tag "None" nil)
- (repeat string)))
-
-(defcustom vm-mime-uuencode-decoder-program "uudecode"
- "*Non-nil value should be a string that names UUENCODE decoder.
-If the program is in your executable search path, you need not
-specify a full pathname. The program should expect to read
-uuencoded data on its standard input and write the converted
-data to the file specified in the ``begin'' line at the start of
-the data."
- :group 'vm-helpers
- :type '(choice (const :tag "None" nil)
- file))
-
-(defcustom vm-mime-uuencode-decoder-switches nil
- "*List of command line flags passed to the command named by
-`vm-mime-uuencode-decoder-program'."
- :group 'vm-helpers
- :type '(choice (const :tag "None" nil)
- (repeat string)))
+(define-obsolete-variable-alias 'vm-mime-uuencode-decoder-switches
+ 'uudecode-decoder-switches "2024")
(defcustom vm-auto-next-message t
"*Non-nil value causes VM to use `vm-next-message' to advance to the next
diff --git a/src/Makefile.in b/src/Makefile.in
deleted file mode 100644
index 6a6b3971a0..0000000000
--- a/src/Makefile.in
+++ /dev/null
@@ -1,43 +0,0 @@
-@SET_MAKE@
-
-##############################################################################
-# no csh please
-SHELL = /bin/sh
-
-SOURCES = $(wildcard *.c)
-
-OBJECTS = $(SOURCES:.c=.o)
-
-##############################################################################
-# location of required programms
-MKDIR = @MKDIR@
-RM = @RM@
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-srcdir = @srcdir@
-bindir = @bindir@
-
-##############################################################################
-all: $(SOURCES:.c=)
-
-install:
- @mkdir -p -m 0755 "$(DESTDIR)$(bindir)"; \
- for i in $(SOURCES:.c=) ; do \
- echo "Installing $$i in $(DESTDIR)$(bindir)" ; \
- $(INSTALL_PROGRAM) $$i "$(DESTDIR)$(bindir)" ; \
- done ;
- @echo VM helper binaries successfully installed\!
-
-##############################################################################
-Makefile: @srcdir@/Makefile.in
- cd ..; ./config.status
-
-##############################################################################
-clean:
- -$(RM) -f $(SOURCES:.c=)
-
-distclean: clean
- -$(RM) -f Makefile
diff --git a/src/base64-decode.c b/src/base64-decode.c
deleted file mode 100644
index d0d3b9a69f..0000000000
--- a/src/base64-decode.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* public domain */
-
-/* BASE64 on stdin -> converted data on stdout */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#ifdef _WIN32
-#ifndef WIN32
-#define WIN32
-#endif
-#endif
-
-#ifdef WIN32
-#include <io.h>
-#include <fcntl.h>
-#endif
-
-unsigned char alphabet[64] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-int
-main()
-{
- static char inalphabet[256], decoder[256];
- int i, bits, c, char_count, errors = 0;
-
-#ifdef WIN32
- _setmode( _fileno(stdout), _O_BINARY);
-#endif
-
- for (i = (sizeof alphabet) - 1; i >= 0 ; i--) {
- inalphabet[alphabet[i]] = 1;
- decoder[alphabet[i]] = i;
- }
-
- char_count = 0;
- bits = 0;
- while ((c = getchar()) != EOF) {
- if (c == '=')
- break;
- if (c > 255 || ! inalphabet[c])
- continue;
- bits += decoder[c];
- char_count++;
- if (char_count == 4) {
- putchar((bits >> 16));
- putchar(((bits >> 8) & 0xff));
- putchar((bits & 0xff));
- bits = 0;
- char_count = 0;
- } else {
- bits <<= 6;
- }
- }
- if (c == EOF) {
- if (char_count) {
- fprintf(stderr, "base64 encoding incomplete: at least %d bits
truncated",
- ((4 - char_count) * 6));
- errors++;
- }
- } else { /* c == '=' */
- switch (char_count) {
- case 1:
- fprintf(stderr, "base64 encoding incomplete: at least 2 bits
missing");
- errors++;
- break;
- case 2:
- putchar((bits >> 10));
- break;
- case 3:
- putchar((bits >> 16));
- putchar(((bits >> 8) & 0xff));
- break;
- }
- }
- exit(errors ? 1 : 0);
-}
diff --git a/src/base64-encode.c b/src/base64-encode.c
deleted file mode 100644
index fd146fa4da..0000000000
--- a/src/base64-encode.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* public domain */
-
-/*
- * arbitrary data on stdin -> BASE64 data on stdout
- *
- * UNIX's newline convention is used, i.e. one ASCII control-j (10 decimal).
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#ifdef _WIN32
-#ifndef WIN32
-#define WIN32
-#endif
-#endif
-
-#ifdef WIN32
-#include <io.h>
-#include <fcntl.h>
-#endif
-
-unsigned char alphabet[64] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-int
-main()
-{
- int cols, bits, c, char_count;
-
-#ifdef WIN32
- _setmode( _fileno(stdin), _O_BINARY);
-#endif
-
- char_count = 0;
- bits = 0;
- cols = 0;
- while ((c = getchar()) != EOF) {
- if (c > 255) {
- fprintf(stderr, "encountered char > 255 (decimal %d)", c);
- exit(1);
- }
- bits += c;
- char_count++;
- if (char_count == 3) {
- putchar(alphabet[bits >> 18]);
- putchar(alphabet[(bits >> 12) & 0x3f]);
- putchar(alphabet[(bits >> 6) & 0x3f]);
- putchar(alphabet[bits & 0x3f]);
- cols += 4;
- if (cols == 72) {
- putchar('\n');
- cols = 0;
- }
- bits = 0;
- char_count = 0;
- } else {
- bits <<= 8;
- }
- }
- if (char_count != 0) {
- bits <<= 16 - (8 * char_count);
- putchar(alphabet[bits >> 18]);
- putchar(alphabet[(bits >> 12) & 0x3f]);
- if (char_count == 1) {
- putchar('=');
- putchar('=');
- } else {
- putchar(alphabet[(bits >> 6) & 0x3f]);
- putchar('=');
- }
- if (cols > 0)
- putchar('\n');
- }
-
- exit(0);
-}
diff --git a/src/qp-decode.c b/src/qp-decode.c
deleted file mode 100644
index 0d6eaa166b..0000000000
--- a/src/qp-decode.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/* public domain */
-
-/* Quoted Printable on stdin -> converted data on stdout */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#ifdef _WIN32
-#ifndef WIN32
-#define WIN32
-#endif
-#endif
-
-#ifdef WIN32
-#include <io.h>
-#include <fcntl.h>
-#endif
-
-char *hexdigits = "0123456789ABCDEF";
-char *hexdigits2 = "0123456789abcdef";
-
-int
-main()
-{
- char line[2000], *start, *stop, *copy;
- char *d1, *d2, c;
- int lineno;
-
-#ifdef WIN32
- _setmode( _fileno(stdout), _O_BINARY);
-#endif
-
- line[sizeof line - 1] = 0;
- lineno = 1;
- while (fgets(line, sizeof line - 1, stdin)) {
- lineno++;
- start = line;
- keep_processing:
- for (stop = start; *stop && *stop != '=' && *stop != '\n'; stop++)
- ;
- if (stop != line && *stop == '\n') {
- copy = stop;
- do {
- copy--;
- if (*copy != ' ' && *copy != '\t') {
- copy++;
- break;
- }
- } while (copy != line);
- } else {
- copy = stop;
- }
- while (start != copy) {
- putchar(*start);
- start++;
- }
- if (*stop == '\n') {
- putchar(*stop);
- lineno++;
- continue;
- } else if (*stop == 0) {
- continue;
- } else { /* *stop == '=' */
- stop++;
- if (*stop == 0) {
- continue;
- } else if ((d1 = strchr(hexdigits, *(stop))) &&
- (d2 = strchr(hexdigits, *(stop+1)))) {
- c = (d1 - hexdigits) * 16 + (d2 - hexdigits);
- putchar(c);
- stop += 2;
- } else if ((d1 = strchr(hexdigits2, *(stop))) &&
- (d2 = strchr(hexdigits2, *(stop+1)))) {
- c = (d1 - hexdigits2) * 16 + (d2 - hexdigits2);
- putchar(c);
- stop += 2;
- } else if (*stop == '\n') {
- /* soft line break */
- stop++;
- } else if (*stop == '\r') {
- /*
- * Assume the user's lousy delivery software
- * didn't convert from Internet's CRLF newline
- * convention to the local LF convention.
- */
- stop++;
- } else if (*stop == ' ' || *stop == '\t') {
- /* garbage added in transit */
- for (stop++; *stop && (*stop == ' ' || *stop == '\t'); stop++)
- ;
- } else {
- fprintf(stderr, "Error: line %d: '%c' is something other than
line break or hex digit after = in quoted-printable encoding\n", lineno, *stop);
- putchar('=');
- putchar(*stop);
- stop++;
- /* exit(1); */
- }
- start = stop;
- goto keep_processing;
- }
- }
- exit(0);
-}
diff --git a/src/qp-encode.c b/src/qp-encode.c
deleted file mode 100644
index e5796d0802..0000000000
--- a/src/qp-encode.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* public domain */
-
-/*
- * arbitrary data on stdin -> Quoted-Printable data on stdout
- *
- * UNIX's newline convention is used, i.e. one ASCII control-j (10 decimal).
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#ifdef _WIN32
-#ifndef WIN32
-#define WIN32
-#endif
-#endif
-
-#ifdef WIN32
-#include <io.h>
-#include <fcntl.h>
-#endif
-
-char *hexdigits = "0123456789ABCDEF";
-
-int
-main()
-{
- int c;
- int cols = 0;
-
-#ifdef WIN32
- _setmode( _fileno(stdout), _O_BINARY);
-#endif
-
- while ((c = getchar()) != EOF) {
- if (c == '\n') {
- putchar(c);
- cols = 0;
- } else if (c == ' ') {
- int nextc = getchar();
- if (nextc != '\n' && nextc != EOF) {
- putchar(c);
- cols++;
- } else {
- putchar('=');
- putchar(hexdigits[c >> 4]);
- putchar(hexdigits[c & 0xf]);
- cols += 3;
- }
- if (nextc != EOF)
- ungetc(nextc, stdin);
- } else if (c < 33 || c > 126 || c == '=' ||
- /* these are for RFC 2047 Q encoding */
- c == '?' || c == '_') {
- putchar('=');
- putchar(hexdigits[c >> 4]);
- putchar(hexdigits[c & 0xf]);
- cols += 3;
- } else if (c == '.' && cols == 0) {
- int nextc = getchar();
- if (nextc == EOF || nextc == '\n') {
- putchar('=');
- putchar(hexdigits[c >> 4]);
- putchar(hexdigits[c & 0xf]);
- cols += 3;
- } else {
- putchar(c);
- cols++;
- }
- if (nextc != EOF)
- ungetc(nextc, stdin);
- } else {
- putchar(c);
- cols++;
- }
- if (cols > 70) {
- putchar('=');
- putchar('\n');
- cols = 0;
- }
- }
- exit(0);
-}