* Boston, MA 02111-1307, USA.
*/
-/* dont touch this file without my permission - Michael */
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
};
+/* generated by gentables.pl and supplied by camel-mime-tables.c */
unsigned short camel_mime_special_table[256];
-static unsigned char camel_mime_base64_rank[256];
-
-/* Used by table initialisation code for special characters */
-#define CHARS_LWSP " \t\n\r"
-#define CHARS_TSPECIAL "()<>@,;:\\\"/[]?="
-#define CHARS_SPECIAL "()<>@,;:\\\".[]"
-#define CHARS_CSPECIAL "()\\\r" /* not in comments */
-#define CHARS_DSPECIAL "[]\\\r \t" /* not in domains */
-#define CHARS_ESPECIAL "()<>@,;:\"/[]?.=_" /* list of characters that must be encoded.
- encoded word in text specials: rfc 2047 5(1)*/
-#define CHARS_PSPECIAL "!*+-/" /* list of additional characters that can be left unencoded.
- encoded word in phrase specials: rfc 2047 5(3) */
-#define CHARS_ATTRCHAR "*\'% " /* extra non-included attribute-chars */
-
-static void
-header_remove_bits(unsigned short bit, unsigned char *vals)
-{
- int i;
-
- for (i=0;vals[i];i++)
- camel_mime_special_table[vals[i]] &= ~ bit;
-}
-
-static void
-header_init_bits(unsigned short bit, unsigned short bitcopy, int remove, unsigned char *vals)
-{
- int i;
- int len = strlen(vals);
-
- if (!remove) {
- for (i=0;i<len;i++) {
- camel_mime_special_table[vals[i]] |= bit;
- }
- if (bitcopy) {
- for (i=0;i<256;i++) {
- if (camel_mime_special_table[i] & bitcopy)
- camel_mime_special_table[i] |= bit;
- }
- }
- } else {
- for (i=0;i<256;i++)
- camel_mime_special_table[i] |= bit;
- for (i=0;i<len;i++) {
- camel_mime_special_table[vals[i]] &= ~bit;
- }
- if (bitcopy) {
- for (i=0;i<256;i++) {
- if (camel_mime_special_table[i] & bitcopy)
- camel_mime_special_table[i] &= ~bit;
- }
- }
- }
-}
-static void
-header_decode_init(void)
-{
- int i;
-
- for (i=0;i<256;i++) {
- camel_mime_special_table[i] = 0;
- if (i<32 || i==127)
- camel_mime_special_table[i] |= CAMEL_MIME_IS_CTRL;
- else if (i < 127)
- camel_mime_special_table[i] |= CAMEL_MIME_IS_ATTRCHAR;
- if ((i>=32 && i<=60) || (i>=62 && i<=126) || i==9)
- camel_mime_special_table[i] |= (CAMEL_MIME_IS_QPSAFE|CAMEL_MIME_IS_ESAFE);
- if ((i>='0' && i<='9') || (i>='a' && i<='z') || (i>='A' && i<= 'Z'))
- camel_mime_special_table[i] |= CAMEL_MIME_IS_PSAFE;
- }
- camel_mime_special_table[' '] |= CAMEL_MIME_IS_SPACE;
- header_init_bits(CAMEL_MIME_IS_LWSP, 0, 0, CHARS_LWSP);
- header_init_bits(CAMEL_MIME_IS_TSPECIAL, CAMEL_MIME_IS_CTRL, 0, CHARS_TSPECIAL);
- header_init_bits(CAMEL_MIME_IS_SPECIAL, 0, 0, CHARS_SPECIAL);
- header_init_bits(CAMEL_MIME_IS_DSPECIAL, 0, FALSE, CHARS_DSPECIAL);
- header_remove_bits(CAMEL_MIME_IS_ESAFE, CHARS_ESPECIAL);
- header_remove_bits(CAMEL_MIME_IS_ATTRCHAR, CHARS_TSPECIAL CHARS_ATTRCHAR);
- header_init_bits(CAMEL_MIME_IS_PSAFE, 0, 0, CHARS_PSPECIAL);
-}
-
-static void
-base64_init(void)
-{
- int i;
-
- memset(camel_mime_base64_rank, 0xff, sizeof(camel_mime_base64_rank));
- for (i=0;i<64;i++) {
- camel_mime_base64_rank[(unsigned int)base64_alphabet[i]] = i;
- }
- camel_mime_base64_rank['='] = 0;
-}
+static unsigned char camel_mime_base64_rank[256] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f,
+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
+ 0x3c, 0x3d, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+ 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
+ 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
+ 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
+ 0x17, 0x18, 0x19, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
+ 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
+ 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
+ 0x31, 0x32, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+};
/* call this when finished encoding everything, to
flush off the last little bit */
{ "List-Unsubscribe", "<mailto:(.+)-unsubscribe@([^ \n\t\r>]*)" },
};
+static pthread_once_t mailing_list_init_once = PTHREAD_ONCE_INIT;
+
+static void
+mailing_list_init(void)
+{
+ int i, errcode, failed=0;
+
+ /* precompile regex's for speed at runtime */
+ for (i = 0; i < G_N_ELEMENTS (mail_list_magic); i++) {
+ errcode = regcomp(&mail_list_magic[i].regex, mail_list_magic[i].pattern, REG_EXTENDED|REG_ICASE);
+ if (errcode != 0) {
+ char *errstr;
+ size_t len;
+
+ len = regerror(errcode, &mail_list_magic[i].regex, NULL, 0);
+ errstr = g_malloc0(len + 1);
+ regerror(errcode, &mail_list_magic[i].regex, errstr, len);
+
+ g_warning("Internal error, compiling regex failed: %s: %s", mail_list_magic[i].pattern, errstr);
+ g_free(errstr);
+ failed++;
+ }
+ }
+
+ g_assert(failed == 0);
+}
+
char *
camel_header_raw_check_mailing_list(struct _camel_header_raw **list)
{
const char *v;
regmatch_t match[3];
int i, j;
-
+
+ pthread_once(&mailing_list_init_once, mailing_list_init);
+
for (i = 0; i < sizeof (mail_list_magic) / sizeof (mail_list_magic[0]); i++) {
v = camel_header_raw_find (list, mail_list_magic[i].name, NULL);
for (j=0;j<3;j++) {
return out;
}
-
-void
-camel_mime_utils_init(void)
-{
- int i, errcode, regex_compilation_failed=0;
-
- /* Init tables */
- header_decode_init();
- base64_init();
-
- /* precompile regex's for speed at runtime */
- for (i = 0; i < G_N_ELEMENTS (mail_list_magic); i++) {
- errcode = regcomp(&mail_list_magic[i].regex, mail_list_magic[i].pattern, REG_EXTENDED|REG_ICASE);
- if (errcode != 0) {
- char *errstr;
- size_t len;
-
- len = regerror(errcode, &mail_list_magic[i].regex, NULL, 0);
- errstr = g_malloc0(len + 1);
- regerror(errcode, &mail_list_magic[i].regex, errstr, len);
-
- g_warning("Internal error, compiling regex failed: %s: %s", mail_list_magic[i].pattern, errstr);
- g_free(errstr);
- regex_compilation_failed++;
- }
- }
-
- g_assert(regex_compilation_failed == 0);
-}
-
-
-void
-camel_mime_utils_shutdown (void)
-{
- int i;
-
- for (i = 0; i < G_N_ELEMENTS (mail_list_magic); i++)
- regfree (&mail_list_magic[i].regex);
-}