File: squishread.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 (135 lines) | stat: -rw-r--r-- 4,041 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
// 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 __SQUISHREAD_H
#define __SQUISHREAD_H

#include <config.h>

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

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

class StatEngine;

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

    /**
     * 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 Squish base header (SQD file). */
    struct sqbase_s
    {
        le_uint16_t len;
        le_uint16_t reserved;
        le_uint32_t num_msg;
        le_uint32_t high_msg;
        le_uint32_t skip_msg;
        le_uint32_t high_water;
        le_uint32_t uid;
        uint8_t     base[80];
        le_uint32_t begin_frame;
        le_uint32_t last_frame;
        le_uint32_t free_frame;
        le_uint32_t last_free_frame;
        le_uint32_t end_frame;
        le_uint32_t max_msg;
        le_uint16_t keep_days;
        le_uint16_t sz_sqhdr;
        uint8_t     reserved2[124];
    };

    /** Structure of the headers of each message (SQD file). */
    struct sqhdr_s
    {
        le_uint32_t id;     //0xAFAE4453
        le_uint32_t next_frame;
        le_uint32_t prev_frame;
        le_uint32_t frame_length;
        le_uint32_t msg_length; //-sizeof(xmsg_s)-clen
        le_uint32_t clen;
        le_uint16_t frame_type;
        le_uint16_t reserved;
    };

    /** Magic number for Squish messages. */
    static const uint32_t Squish_id = 0xAFAE4453;
    /** Frame type for normal Squish messages. */
    static const uint16_t Squish_type_normal = 0;
    /** Frame type for free Squish frames. */
    static const uint16_t Squish_type_free = 1;

    /** Structure of the XMSG header that precedes each message. */
    struct xmsg_s
    {
        le_uint32_t attr;
        uint8_t     from[36];
        uint8_t     to[36];
        uint8_t     subject[72];
        le_uint16_t origzone;
        le_uint16_t orignet;
        le_uint16_t orignode;
        le_uint16_t origpoint;
        le_uint16_t destzone;
        le_uint16_t destnet;
        le_uint16_t destnode;
        le_uint16_t destpoint;
        stamp_s     date_written;
        stamp_s     date_arrived;
        le_int16_t  utc_ofs;
        le_uint32_t replyto;
        le_uint32_t replies[9];
        le_uint32_t umsgid;
        uint8_t     ftsc_date[20];
    };
};

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

#endif