Switch to unified view

a/src/bincimapmime/trbinc.cc b/src/bincimapmime/trbinc.cc
1
#ifndef     lint
1
#ifndef     lint
2
static char rcsid [] = "@(#$Id: trbinc.cc,v 1.1 2005-03-25 09:40:27 dockes Exp $  (C) 1994 CDKIT";
2
static char rcsid [] = "@(#$Id: trbinc.cc,v 1.2 2005-03-31 10:04:07 dockes Exp $  (C) 1994 CDKIT";
3
#endif
3
#endif
4
4
5
#include <stdio.h>
5
#include <stdio.h>
6
#include <stdlib.h>
6
#include <stdlib.h>
7
#include <unistd.h>
7
#include <unistd.h>
8
#include <errno.h>
8
#include <errno.h>
9
#include <string.h>
9
#include <string.h>
10
#include <fcntl.h>
10
#include <fcntl.h>
11
12
#include <sstream>
13
14
using namespace std;
11
15
12
#include "mime.h"
16
#include "mime.h"
13
17
14
static char *thisprog;
18
static char *thisprog;
15
19
...
...
66
    if ((fd = open(mfile, 0)) < 0) {
70
    if ((fd = open(mfile, 0)) < 0) {
67
    perror("Opening");
71
    perror("Opening");
68
    exit(1);
72
    exit(1);
69
    }
73
    }
70
    Binc::MimeDocument doc;
74
    Binc::MimeDocument doc;
75
76
#if 0
71
    doc.parseFull(fd);
77
    doc.parseFull(fd);
78
#else
79
    char *cp;
80
    int size = lseek(fd, 0, SEEK_END);
81
    lseek(fd, 0, 0);
82
    fprintf(stderr, "Size: %d\n", size);
83
    cp = (char *)malloc(size);
84
    if (cp==0) {
85
  fprintf(stderr, "Malloc %d failed\n", size);
86
  exit(1);
87
    }
88
    int n;
89
    if ((n=read(fd, cp, size)) != size) {
90
  fprintf(stderr, "Read failed: requested %d, got %d\n", size, n);
91
  exit(1);
92
    }
93
    std::stringstream s(string(cp, size), ios::in);
94
    doc.parseFull(s);
95
#endif
72
96
73
    if (!doc.isHeaderParsed() && !doc.isAllParsed()) {
97
    if (!doc.isHeaderParsed() && !doc.isAllParsed()) {
74
    fprintf(stderr, "Parse error\n");
98
    fprintf(stderr, "Parse error\n");
75
    exit(1);
99
    exit(1);
76
    }
100
    }