--- /dev/null
+Important note for Camel hackers:
+---------------------------------
+
+Camel has been a lot of work, and has been conceived to be general
+enough to be used outside the gnome-mailer. It is possible in the
+future that it is used in softwares with licenses incompatible with the
+LGPL. For this reason, the copyright has to be owned by a unique
+person. Be sure, however, that Camel will always be available under
+the LGPL. Significant authors will always be consulted before any
+special use of Camel. Moreover, in special situations, they may be
+given the authorization to use Camel with a license different than the
+LGPL.
+
+Thus, when adding code in Camel, always add the following lines at the
+begining of the file:
+
+/*
+ *
+ * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> .
+ *
+ * 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 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+You may also want to add your name to the author name list after this
+header.
+
+Please contact me (Bertrand.Guiheneuf@aful.org) if you want to discuss
+this copyright issue.
+
+Happy hacking,
+
+Bertrand.
+
+
*
*/
+/*
+ * Authors: Robert Brady <rwb197@ecs.soton.ac.uk>
+ */
+
#include <stdio.h>
#include <ctype.h>
#include <unicode.h>
static int base64_rank_table_built;
static void build_base64_rank_table (void);
-static int hexval(gchar c) {
- if (isdigit(c)) return c-'0';
- c = tolower(c);
+static int
+hexval (gchar c) {
+ if (isdigit (c)) return c-'0';
+ c = tolower (c);
return c - 'a' + 10;
}
-static void decode_quoted(const gchar *text, gchar *to) {
+static void
+decode_quoted (const gchar *text, gchar *to)
+{
while (*text) {
if (*text == '=') {
- gchar a = hexval(text[1]);
- gchar b = hexval(text[2]);
+ gchar a = hexval (text[1]);
+ gchar b = hexval (text[2]);
int c = (a << 4) + b;
*to = c;
to++;
*to = 0;
}
-static
-void decode_base64 (const gchar *what, gchar *where)
+static void
+decode_base64 (const gchar *what, gchar *where)
{
unsigned short pattern = 0;
int bits = 0;
{
gchar buffer[4096] /* FIXME : constant sized buffer */, *b = buffer;
- build_base64_rank_table();
+ build_base64_rank_table ();
while (*data) {
if (!encoding) break;
encoding++;
- text = strchr(encoding, '?');
+ text = strchr (encoding, '?');
if (!text) break;
text++;
- end = strstr(text, "?=");
+ end = strstr (text, "?=");
if (!end) break;
end++;
*(text-1)=0;
*(end-1)=0;
- if (strcasecmp(encoding, "q")==0) {
+ if (strcasecmp (encoding, "q") == 0) {
decode_quoted(text, dc);
- } else if (strcasecmp(encoding, "b")==0) {
- decode_base64(text, dc);
+ } else if (strcasecmp (encoding, "b") == 0) {
+ decode_base64 (text, dc);
} else {
/* What to do here? */
break;
int f;
iconv_t i;
const gchar *d2 = dc;
- int l = strlen(d2), l2 = 4000;
+ int l = strlen (d2), l2 = 4000;
- i = unicode_iconv_open(into_what, charset);
+ i = unicode_iconv_open (into_what, charset);
if (!i)
break;
- unicode_iconv(i, &d2, &l, &b, &l2);
+ unicode_iconv (i, &d2, &l, &b, &l2);
- unicode_iconv_close(i);
+ unicode_iconv_close (i);
data = end;
}
}
- }
- else {
+ } else {
*b = *data;
b++;
}
*b = 0;
- return g_strdup(buffer);
+ return g_strdup (buffer);
}
gchar
}
if (!not_ascii) {
- b += sprintf(b, "%s", string);
+ b += sprintf (b, "%s", string);
}
else {
- b += sprintf(b, "=?%s?Q?", charset);
+ b += sprintf (b, "=?%s?Q?", charset);
s = string;
while (*s) {
- if (*s == ' ') b += sprintf(b, "_");
+ if (*s == ' ') b += sprintf (b, "_");
else if (*s < 0x20 || *s >= 0x7f || *s == '=' || *s == '?' || *s == '_') {
- b += sprintf(b, "=%2x", *s);
+ b += sprintf (b, "=%2x", *s);
} else {
- b += sprintf(b, "%c", *s);
+ b += sprintf (b, "%c", *s);
}
s++;
}
- b += sprintf(b, "?=");
+ b += sprintf (b, "?=");
}
*b = 0;
- return g_strdup(buffer);
+ return g_strdup (buffer);
}