~ubuntu-branches/ubuntu/natty/evolution-data-server/natty

« back to all changes in this revision

Viewing changes to camel/camel-mime-utils.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
514
514
        register gint sofar = *save;  /* keeps track of how many chars on a line */
515
515
        register gint last = *statep; /* keeps track if last gchar to end was a space cr etc */
516
516
 
 
517
        #define output_last()                           \
 
518
                if (sofar + 3 > 74) {                   \
 
519
                        *outptr++ = '=';                \
 
520
                        *outptr++ = '\n';               \
 
521
                        sofar = 0;                      \
 
522
                }                                       \
 
523
                *outptr++ = '=';                        \
 
524
                *outptr++ = tohex[(last >> 4) & 0xf];   \
 
525
                *outptr++ = tohex[last & 0xf];          \
 
526
                sofar += 3;
 
527
 
517
528
        inptr = in;
518
529
        inend = in + len;
519
530
        outptr = out;
521
532
                c = *inptr++;
522
533
                if (c == '\r') {
523
534
                        if (last != -1) {
524
 
                                *outptr++ = '=';
525
 
                                *outptr++ = tohex[(last >> 4) & 0xf];
526
 
                                *outptr++ = tohex[last & 0xf];
527
 
                                sofar += 3;
 
535
                                output_last ();
528
536
                        }
529
537
                        last = c;
530
538
                } else if (c == '\n') {
531
539
                        if (last != -1 && last != '\r') {
532
 
                                *outptr++ = '=';
533
 
                                *outptr++ = tohex[(last >> 4) & 0xf];
534
 
                                *outptr++ = tohex[last & 0xf];
 
540
                                output_last ();
535
541
                        }
536
542
                        *outptr++ = '\n';
537
543
                        sofar = 0;
542
548
                                        *outptr++ = last;
543
549
                                        sofar++;
544
550
                                } else {
545
 
                                        *outptr++ = '=';
546
 
                                        *outptr++ = tohex[(last >> 4) & 0xf];
547
 
                                        *outptr++ = tohex[last & 0xf];
548
 
                                        sofar += 3;
 
551
                                        output_last ();
549
552
                                }
550
553
                        }
551
554
 
582
585
        *save = sofar;
583
586
        *statep = last;
584
587
 
 
588
        #undef output_last
 
589
 
585
590
        return (outptr - out);
586
591
}
587
592
 
1433
1438
                                inptr += convlen;
1434
1439
                        } else {
1435
1440
                                /* make sure we flush out any shift state */
1436
 
                                camel_iconv (ic, NULL, 0, &out, &outlen);
 
1441
                                camel_iconv (ic, NULL, NULL, &out, &outlen);
1437
1442
                        }
1438
1443
                        inlen -= (inptr - p);
1439
1444
                }
2063
2068
 
2064
2069
        ret = camel_iconv(ic, &in, &inlen, &outbuf, &outlen);
2065
2070
        if (ret != (gsize) -1) {
2066
 
                camel_iconv(ic, NULL, 0, &outbuf, &outlen);
 
2071
                camel_iconv(ic, NULL, NULL, &outbuf, &outlen);
2067
2072
                *outbuf = '\0';
2068
2073
                result = g_strdup(outbase);
2069
2074
        }
2166
2171
                return NULL;
2167
2172
 
2168
2173
        pn = g_malloc (sizeof (*pn));
2169
 
        pn->next = 0;
 
2174
        pn->next = NULL;
2170
2175
        pn->name = g_strdup (name);
2171
2176
        pn->value = g_strdup (value);
2172
2177
        p->next = pn;
2837
2842
                w = w->next;
2838
2843
        n = g_malloc(sizeof(*n));
2839
2844
        n->id = ref;
2840
 
        n->next = 0;
 
2845
        n->next = NULL;
2841
2846
        w->next = n;
2842
2847
}
2843
2848
 
3041
3046
const gchar *
3042
3047
camel_transfer_encoding_to_string (CamelTransferEncoding encoding)
3043
3048
{
3044
 
        if (encoding >= sizeof (encodings) / sizeof (encodings[0]))
 
3049
        if (encoding >= G_N_ELEMENTS (encodings))
3045
3050
                encoding = 0;
3046
3051
 
3047
3052
        return encodings[encoding];
3053
3058
        gint i;
3054
3059
 
3055
3060
        if (string != NULL) {
3056
 
                for (i = 0; i < sizeof (encodings) / sizeof (encodings[0]); i++)
 
3061
                for (i = 0; i < G_N_ELEMENTS (encodings); i++)
3057
3062
                        if (!g_ascii_strcasecmp (string, encodings[i]))
3058
3063
                                return i;
3059
3064
        }
3309
3314
        out = g_string_new (charset);
3310
3315
        g_string_append(out, "''");
3311
3316
 
3312
 
        while ( (c = *inptr++) ) {
 
3317
        while ((c = *inptr++)) {
3313
3318
                if (camel_mime_is_attrchar(c))
3314
3319
                        g_string_append_c (out, c);
3315
3320
                else
3324
3329
        return str;
3325
3330
}
3326
3331
 
3327
 
/* HACK: Set to non-zero when you want the 'filename' and 'name' headers encode in RFC 2047 way,
 
3332
/* HACK: Set to non-zero when you want the 'filename' and 'name' headers encoded in RFC 2047 way,
3328
3333
   otherwise they will be encoded in the correct RFC 2231 way. It's because Outlook and GMail
3329
3334
   do not understand the correct standard and refuse attachments with localized name sent
3330
 
   from evolution. */
 
3335
   from evolution. This seems to have been fixed in Exchange 2007 at least - not sure about
 
3336
   standalone Outlook. */
3331
3337
gint camel_header_param_encode_filenames_in_rfc_2047 = 0;
3332
3338
 
3333
3339
void
3696
3702
 * Allocates a string buffer containing the rfc822 formatted date
3697
3703
 * string represented by @time and @tz_offset.
3698
3704
 *
3699
 
 * Return value: a valid string representation of the date.
 
3705
 * Returns: a valid string representation of the date.
3700
3706
 **/
3701
3707
gchar *
3702
3708
camel_header_format_date (time_t date, gint tz_offset)
4228
4234
                quote = 1;
4229
4235
        }
4230
4236
 
4231
 
        while ( (c = *in++) ) {
 
4237
        while ((c = *in++)) {
4232
4238
                if (quote && c=='"')
4233
4239
                        break;
4234
4240
                if (!camel_mime_is_lwsp(c))
4534
4540
 
4535
4541
        pthread_once(&mailing_list_init_once, mailing_list_init);
4536
4542
 
4537
 
        for (i = 0; i < sizeof (mail_list_magic) / sizeof (mail_list_magic[0]); i++) {
 
4543
        for (i = 0; i < G_N_ELEMENTS (mail_list_magic); i++) {
4538
4544
                v = camel_header_raw_find (list, mail_list_magic[i].name, NULL);
4539
4545
                for (j=0;j<3;j++) {
4540
4546
                        match[j].rm_so = -1;