claws-mail/src/common/uuencode.c
Colin Leroy 0539d68af9 2007-10-15 [colin] 3.0.2cvs76
* src/edittags.c
	* src/edittags.h
	* src/filtering.c
	* src/filtering.h
	* src/importmutt.c
	* src/importpine.c
	* src/main.c
	* src/messageview.c
	* src/messageview.h
	* src/mimeview.c
	* src/mimeview.h
	* src/pop.c
	* src/pop.h
	* src/prefs_common.c
	* src/prefs_common.h
	* src/prefs_customheader.c
	* src/prefs_customheader.h
	* src/prefs_display_header.c
	* src/prefs_display_header.h
	* src/prefs_filtering_action.c
	* src/prefs_filtering_action.h
	* src/prefs_folder_column.c
	* src/prefs_folder_column.h
	* src/prefs_folder_item.c
	* src/prefs_folder_item.h
	* src/prefs_gtk.c
	* src/prefs_gtk.h
	* src/prefs_logging.h
	* src/prefs_matcher.c
	* src/prefs_matcher.h
	* src/prefs_summary_column.c
	* src/prefs_summary_column.h
	* src/prefs_summary_open.c
	* src/procheader.c
	* src/procheader.h
	* src/procmime.c
	* src/procmime.h
	* src/recv.c
	* src/recv.h
	* src/sourcewindow.c
	* src/sourcewindow.h
	* src/summaryview.c
	* src/summaryview.h
	* src/textview.c
	* src/textview.h
	* src/toolbar.c
	* src/toolbar.h
	* src/common/mgutils.c
	* src/common/mgutils.h
	* src/common/nntp.c
	* src/common/nntp.h
	* src/common/prefs.c
	* src/common/prefs.h
	* src/common/socket.c
	* src/common/socket.h
	* src/common/stringtable.c
	* src/common/stringtable.h
	* src/common/template.c
	* src/common/template.h
	* src/common/uuencode.c
	* src/common/uuencode.h
	* src/gtk/gtkshruler.c
	* src/gtk/gtkshruler.h
	* src/gtk/menu.c
	* src/gtk/menu.h
	* src/gtk/progressdialog.c
	* src/gtk/progressdialog.h
		Remove/staticalize, the return of the revenge
2007-10-15 17:20:02 +00:00

71 lines
2 KiB
C

/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
* Copyright (C) 1999,2000 Hiroyuki Yamamoto
*
* 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <ctype.h>
#define UUDECODE(c) (c=='`' ? 0 : c - ' ')
#define N64(i) (i & ~63)
const char uudigit[64] =
{
'`', '!', '"', '#', '$', '%', '&', '\'',
'(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', '\\', ']', '^', '_'
};
int fromuutobits(char *out, const char *in)
{
int len, outlen, inlen;
register unsigned char digit1, digit2;
outlen = UUDECODE(in[0]);
in += 1;
if(outlen < 0 || outlen > 45)
return -2;
if(outlen == 0)
return 0;
inlen = (outlen * 4 + 2) / 3;
len = 0;
for( ; inlen>0; inlen-=4) {
digit1 = UUDECODE(in[0]);
if (N64(digit1)) return -1;
digit2 = UUDECODE(in[1]);
if (N64(digit2)) return -1;
out[len++] = (digit1 << 2) | (digit2 >> 4);
if (inlen > 2) {
digit1 = UUDECODE(in[2]);
if (N64(digit1)) return -1;
out[len++] = (digit2 << 4) | (digit1 >> 2);
if (inlen > 3) {
digit2 = UUDECODE(in[3]);
if (N64(digit2)) return -1;
out[len++] = (digit1 << 6) | digit2;
}
}
in += 4;
}
return len == outlen ? len : -3;
}