Extending test-client-custom-summary to try e_book_client_get_contacts_uids()
[platform/upstream/evolution-data-server.git] / camel / gentables.pl
1 #!/usr/bin/perl
2
3 %special = (
4     "CHARS_LWSP", " \t\n\r",
5     "CHARS_TSPECIAL", "()<>@,;:\\\"/[]?=",
6     "CHARS_SPECIAL", "()<>@,;:\\\".[]",
7     "CHARS_CSPECIAL", "()\\\r", # not in comments
8     "CHARS_DSPECIAL", "[]\\\r \t",      # not in domains
9     "CHARS_ATTRCHAR", "*\'% " );        # extra non-included attribute-chars
10
11 %bits = (
12     CAMEL_MIME_IS_CTRL  , 1<<0,
13     CAMEL_MIME_IS_LWSP  , 1<<1,
14     CAMEL_MIME_IS_TSPECIAL      , 1<<2,
15     CAMEL_MIME_IS_SPECIAL       , 1<<3,
16     CAMEL_MIME_IS_SPACE , 1<<4,
17     CAMEL_MIME_IS_DSPECIAL      , 1<<5,
18     CAMEL_MIME_IS_QPSAFE        , 1<<6,
19     CAMEL_MIME_IS_ESAFE , 1<<7, #/* encoded word safe */
20     CAMEL_MIME_IS_PSAFE , 1<<8, #/* encoded word in phrase safe */
21     CAMEL_MIME_IS_ATTRCHAR  , 1<<9,     #/* attribute-char safe (rfc2184) */
22 );
23
24 @table = ();
25
26 # set bit in character positions
27 sub add_bits {
28     my $bit = $_[0];
29     my $str = $_[1];
30     my $ch;
31
32     foreach $ch (split(/.{0}/, $str)) {
33         $table[ord($ch)] |= $bits{$bit};
34     }
35 };
36
37 # remove bit in character positions
38 sub rem_bits {
39     my $bit = $_[0];
40     my $str = $_[1];
41     my $ch;
42
43     foreach $ch (split(/.{0}/, $str)) {
44         $table[ord($ch)] &= ~($bits{$bit});
45     }
46 };
47
48 # set up base ranges
49 foreach $i (0 .. 255) {
50     $table[$i] = 0;
51     if ($i<32 || $i==127) {
52         $table[$i] |= $bits{CAMEL_MIME_IS_CTRL} | $bits{CAMEL_MIME_IS_TSPECIAL};
53     } elsif ($i < 127) {
54         $table[$i] |= $bits{CAMEL_MIME_IS_ATTRCHAR};
55     }
56     if (($i>=32 && $i<=60) || ($i>=62 && $i<=126) || $i==9) {
57         $table[$i] |= ($bits{CAMEL_MIME_IS_QPSAFE} | $bits{CAMEL_MIME_IS_ESAFE});
58     }
59     if (($i>=0x30 && $i<=0x39) || ($i>=0x61 && $i<=0x7a) || ($i>=0x41 && $i<= 0x5a)) {
60         $table[$i] |= $bits{CAMEL_MIME_IS_PSAFE};
61     }
62 }
63
64 $table[0x20] |= $bits{CAMEL_MIME_IS_SPACE};
65
66 add_bits('CAMEL_MIME_IS_LWSP', " \t\n\r");
67 add_bits('CAMEL_MIME_IS_TSPECIAL', "()<>@,;:\\\"/[]?=");
68 add_bits('CAMEL_MIME_IS_SPECIAL', "()<>@,;:\\\".[]");
69 # not in domains
70 add_bits('CAMEL_MIME_IS_DSPECIAL', "[]\\\r \t");
71
72 # list of characters that must be encoded.
73 # encoded word in text specials: rfc 2047 5(1)
74 rem_bits('CAMEL_MIME_IS_ESAFE', "()<>@,;:\"/[]?.=_");
75
76 # non-included attribute-chars (tspecial + extra)
77 rem_bits('CAMEL_MIME_IS_ATTRCHAR', "*\'% "."()<>@,;:\\\"/[]?=");
78
79 # list of additional characters that can be left unencoded.
80 # encoded word in phrase specials: rfc 2047 5(3)
81 add_bits('CAMEL_MIME_IS_PSAFE', "!*+-/");
82
83
84 #header_init_bits(CAMEL_MIME_IS_LWSP, 0, 0, CHARS_LWSP);
85 #header_init_bits(CAMEL_MIME_IS_TSPECIAL, CAMEL_MIME_IS_CTRL, 0, CHARS_TSPECIAL);
86 #header_init_bits(CAMEL_MIME_IS_SPECIAL, 0, 0, CHARS_SPECIAL);
87 #header_init_bits(CAMEL_MIME_IS_DSPECIAL, 0, FALSE, CHARS_DSPECIAL);
88 #header_remove_bits(CAMEL_MIME_IS_ESAFE, CHARS_ESPECIAL);
89 #header_remove_bits(CAMEL_MIME_IS_ATTRCHAR, CHARS_TSPECIAL CHARS_ATTRCHAR);
90 #header_init_bits(CAMEL_MIME_IS_PSAFE, 0, 0, CHARS_PSPECIAL);
91
92 # output
93 print "const unsigned short camel_mime_special_table[256] = {\n\t";
94 foreach $i (0..255) {
95     printf "0x%04x,", $table[$i];
96     if (($i & 0x7) == 0x7) {
97         print "\n";
98         if ($i != 0xff) {
99             print "\t";
100         }
101     } else {
102         print " ";
103     }
104 }
105 print "};\n";