~ubuntu-branches/ubuntu/saucy/edbrowse/saucy

« back to all changes in this revision

Viewing changes to src/fetchmail.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2010-11-29 12:06:07 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20101129120607-murkfny32efpr1nx
Tags: 3.4.5-0ubuntu1
* New upstream release
* Convert to source format 3.0
  - add debian/format/source
* Update for xulrunner-2.0
  - update debian/control
  - add debian/patches/spidermonkey-2.0.patch for the JSNative changes
  - add debian/patches/series
* Don't call the xulrunner binary to find libmozjs
  - update debian/edbrowse.sh
* Pass -lcrypto and -lreadline to the linker
  - update debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
271
271
    }
272
272
}                               /* writeAttachments */
273
273
 
274
 
static void
275
 
serverPutGet(const char *line, bool secure)
276
 
{
277
 
    if(!serverPutLine(line, secure))
278
 
        showErrorAbort();
279
 
    if(!serverGetLine(secure))
280
 
        showErrorAbort();
281
 
}                               /* serverPutGet */
282
 
 
283
274
void
284
275
fetchMail(int account)
285
276
{
304
295
 
305
296
    if(!mailConnect(host, a->inport, a->inssl))
306
297
        showErrorAbort();
307
 
    if(!serverGetLine(a->inssl))
 
298
    if(!mailGetLine())
308
299
        showErrorAbort();
309
300
    if(memcmp(serverLine, "+OK ", 4))
310
301
        i_printfExit(MSG_BadPopIntro, serverLine);
311
302
    sprintf(serverLine, "user %s%s", login, eol);
312
 
    serverPutGet(serverLine, a->inssl);
 
303
    mailPutGetError(serverLine);
313
304
    if(pass) {                  /* I think this is always required */
314
305
        sprintf(serverLine, "pass %s%s", pass, eol);
315
 
        serverPutGet(serverLine, a->inssl);
 
306
        mailPutGetError(serverLine);
316
307
    }                           /* password */
317
308
    if(memcmp(serverLine, "+OK", 3))
318
309
        i_printfExit(MSG_PopNotComplete, serverLine);
319
310
 
320
311
/* How many mail messages? */
321
 
    serverPutGet("stat\r\n", a->inssl);
 
312
    mailPutGetError("stat\r\n");
322
313
    if(memcmp(serverLine, "+OK ", 4))
323
314
        i_printfExit(MSG_NoStatusMailBox, serverLine);
324
315
    nmsgs = atoi(serverLine + 4);
325
316
    if(!nmsgs) {
326
317
        i_puts(MSG_NoMail);
327
 
        serverClose(a->inssl);
 
318
        mailClose();
328
319
        exit(0);
329
320
    }
330
321
 
371
362
            cxSwitch(1, false);
372
363
/* Now grab the entire message */
373
364
            sprintf(serverLine, "retr %d%s", m, eol);
374
 
            if(!serverPutLine(serverLine, a->inssl))
 
365
            if(!mailPutLine(serverLine, false))
375
366
                showErrorAbort();
376
367
            retr1 = true;
377
368
            while(true) {
418
409
            }
419
410
            exact_l = j;
420
411
 
421
 
/* get rid of the dos returns */
 
412
/* get rid of the dos returns, and dot strip */
422
413
            for(j = k = 0; j < exact_l; ++j) {
 
414
                if(!j && exact[j] == '.')
 
415
                    continue;
 
416
                if(j && exact[j] == '.' && exact[j - 1] == '\n')
 
417
                    continue;
423
418
                if(exact[j] == '\r' && j < exact_l - 1 && exact[j + 1] == '\n')
424
419
                    continue;
425
420
                exact[k++] = exact[j];
467
462
                    nl();
468
463
                } else if(!nattach &&   /* drop empty mail message */
469
464
                   cw->dol -
470
 
                   (lastMailInfo->subject != 0) -
471
 
                   (lastMailInfo->from != 0) -
472
 
                   (lastMailInfo->reply != 0) <= 1) {
 
465
                   (strlen(lastMailInfo->subject) != 0) -
 
466
                   (strlen(lastMailInfo->from) != 0) -
 
467
                   (strlen(lastMailInfo->reply) != 0) <= 1) {
473
468
                    redirect = "x";
474
469
                    i_puts(MSG_Empty);
475
470
                }
507
502
                        switch (key) {
508
503
                        case 'q':
509
504
                            i_puts(MSG_Quit);
510
 
                            serverClose(a->inssl);
 
505
                            mailClose();
511
506
                        case 'x':
512
507
                            exit(0);
513
508
                        case 'n':
628
623
 * So if you didn't mean to delete, type x to exit abruptly,
629
624
 * then fetch your mail again. */
630
625
            sprintf(serverLine, "dele %d%s", m, eol);
631
 
            if(!serverPutLine(serverLine, a->inssl))
 
626
            if(!mailPutLine(serverLine, false))
632
627
                showErrorAbort();
633
 
            if(!serverGetLine(a->inssl))
 
628
            if(!mailGetLine())
634
629
                i_printfExit(MSG_MailTimeOver);
635
630
            if(memcmp(serverLine, "+OK", 3))
636
631
                i_printfExit(MSG_UnableDelMail, serverLine);
642
637
 
643
638
    if(zapMail)
644
639
        printf("%d\n", nmsgs);
645
 
    serverClose(a->inssl);
 
640
    mailClose();
646
641
    exit(0);
647
642
}                               /* fetchMail */
648
643
 
1864
1859
            continue;
1865
1860
        }
1866
1861
 
 
1862
        if(memEqualCI(p, "references:", 11)) {
 
1863
            linetype[j] = 'v';
 
1864
            continue;
 
1865
        }
 
1866
 
1867
1867
        if(memEqualCI(p, "reply to ", 9)) {
1868
1868
            linetype[j] = 'r';
1869
1869
            repln = j;
1887
1887
    }
1888
1888
 
1889
1889
/* delete the lines we don't need */
1890
 
    for(j = 6; j >= 1; --j) {
1891
 
        if(!strchr("wfta", linetype[j]))
 
1890
    linetype[j] = 0;
 
1891
    for(--j; j >= 1; --j) {
 
1892
        if(strchr("srv", linetype[j]))
1892
1893
            continue;
1893
1894
        delText(j, j);
1894
1895
        strcpy(linetype + j, linetype + j + 1);
1895
1896
    }
1896
1897
 
1897
1898
/* move reply to 1, if it isn't already there */
1898
 
    if(linetype[1] != 'r') {
 
1899
    repln = strchr(linetype, 'r') - linetype;
 
1900
    subln = strchr(linetype, 's') - linetype;
 
1901
    if(repln != 1) {
1899
1902
        char *map = cw->map;
1900
1903
        char swap[LNWIDTH];
1901
1904
        char *q1 = map + LNWIDTH;
1902
 
        char *q2 = map + LNWIDTH * 2;
 
1905
        char *q2 = map + LNWIDTH * repln;
 
1906
        memcpy(swap, q1, LNWIDTH);
 
1907
        memcpy(q1, q2, LNWIDTH);
 
1908
        memcpy(q2, swap, LNWIDTH);
 
1909
        if(subln == 1)
 
1910
            subln = repln;
 
1911
        repln = 1;
 
1912
    }
 
1913
 
 
1914
    j = strlen(linetype) - 1;
 
1915
    if(j != subln) {
 
1916
        char *map = cw->map;
 
1917
        char swap[LNWIDTH];
 
1918
        char *q1 = map + LNWIDTH * j;
 
1919
        char *q2 = map + LNWIDTH * subln;
1903
1920
        memcpy(swap, q1, LNWIDTH);
1904
1921
        memcpy(q1, q2, LNWIDTH);
1905
1922
        memcpy(q2, swap, LNWIDTH);
1945
1962
    if(t[1] == '>') {
1946
1963
        i_puts(MSG_ReNoID);
1947
1964
    } else {
1948
 
        stringAndString(&out, &j, "references: <");
 
1965
        stringAndString(&out, &j, "References: <");
1949
1966
        if(*s != '>') {
1950
1967
            stringAndBytes(&out, &j, s, t - s);
1951
1968
            stringAndString(&out, &j, "> <");