File: jamread.h

package info (click to toggle)
turqstat 3.0-2
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 2,112 kB
  • ctags: 1,328
  • sloc: cpp: 17,929; perl: 252; makefile: 223; ansic: 75; sh: 16
file content (150 lines) | stat: -rw-r--r-- 4,959 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// Copyright (c) 1999-2007 Peter Karlsson
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#ifndef __JAMREAD_H
#define __JAMREAD_H

#include <config.h>

#include "datatypes.h"
#include "arearead.h"

#if defined(__GNUC__) || defined(__EMX__)
# pragma pack(push, 1)
#endif

class StatEngine;

/**
 * Class that reads JAM message bases.
 * This class reads message bases stored in the JAM format.
 */
class JamRead : public AreaRead
{
public:
    /** Standard constructor.
     * Creates the JAM message base reader object.
     * @param path Directory and base name for message base.
     */
    JamRead(const char *path);
    /** Standard destructor. */
    virtual ~JamRead();

    /**
     * Transfer function. 
     * This function transfers all messages in the message bases, received
     * after the specified starting date, to the specified statistics engine.
     *
     * @param starttime   Date to start retrieve statistics from.
     * @param endtime     Date to stop retrieve statistics at.
     * @param destination Engine object to transfer data to.
     * @return True if the message base was read correctly (even if no
     *         messages fits the condition).
     */
    virtual bool Transfer(time_t starttime, time_t endtime,
                          StatEngine &destination);

protected:
    /** Path to message base. */
    char        *areapath;

    /** Structure of the header in the JHR file. */
    struct jamhdr_header_s
    {
        uint8_t     signature[4];   // 'JAM\0'
        le_uint32_t datecreated;
        le_uint32_t modcounter;
        le_uint32_t activemsgs;
        le_uint32_t passwordcrc;
        le_uint32_t basemsgnum;
        uint8_t     _reserved[1000];
    };

    /** Structure of the JHR entry for individual messages. */
    struct jamhdr_msg_s
    {
        uint8_t     signature[4];   // 'JAM\0'
        le_uint16_t revision;
        le_uint16_t _reserved;
        le_uint32_t subfieldlen;
        le_uint32_t timesread;
        le_uint32_t msgidcrc;
        le_uint32_t replycrc;
        le_uint32_t replyto;
        le_uint32_t reply1st;
        le_uint32_t replynext;
        le_uint32_t datewritten;
        le_uint32_t datereceived;
        le_uint32_t dateprocessed;
        le_uint32_t messagenumber;
        le_uint32_t attribute;
        le_uint32_t _attribute2;
        le_uint32_t offset;
        le_uint32_t txtlen;
        le_uint32_t passwordcrc;
        le_uint32_t cost;
    };

    /** JAM attribute denoting a deleted message. */
    static const uint32_t Jam_deleted = 0x80000000L;

    /** Common data fields for the JHR message subheaders. */
    struct jamhdr_subhdr_s
    {
        le_uint16_t loid;
        le_uint16_t _hiid;
        le_uint32_t datlen;
     /* uint8_t     buffer[datlen]; */
    };

    static const uint16_t Jam_oaddress    = 0;      // Ignored
    static const uint16_t Jam_daddress    = 1;      // Ignored
    static const uint16_t Jam_sender      = 2;
    static const uint16_t Jam_recipient   = 3;
    static const uint16_t Jam_MSGID       = 4;
    static const uint16_t Jam_REPLY       = 5;      // Ignored
    static const uint16_t Jam_subject     = 6;
    static const uint16_t Jam_PID         = 7;
    static const uint16_t Jam_VIA         = 8;      // Ignored
    static const uint16_t Jam_fileattach  = 9;      // Ignored
    static const uint16_t Jam_filealias   = 10;     // Ignored
    static const uint16_t Jam_freq        = 11;     // Ignored
    static const uint16_t Jam_filewildcard= 12;     // Ignored
    static const uint16_t Jam_attachlist  = 13;     // Ignored
    static const uint16_t Jam_reserved    = 1000;   // Ignored
    static const uint16_t Jam_kludge      = 2000;
    static const uint16_t Jam_SEENBY      = 2001;   // Ignored
    static const uint16_t Jam_PATH        = 2002;   // Ignored
    static const uint16_t Jam_FLAGS       = 2003;   // Ignored
    static const uint16_t Jam_TZUTC       = 2004;   // Ignored

    /** Structure of the JDX entry JDX for individual messages. */
    struct jamjdx_s
    {
        le_uint32_t recipientcrc;
        le_uint32_t jhroffset;
    };

    /** Version of JAM message bases supported. */
    static const uint16_t Jam_msgbaseversion = 1;
    /** Magic number for JAM. */
    static const uint8_t  Jam_signature[4];
};

#if defined(__GNUC__) || defined(__EMX__)
# pragma pack(pop)
#endif

#endif