File: adc.h

package info (click to toggle)
clamav 0.98.7+dfsg-0+deb6u2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 60,204 kB
  • ctags: 49,129
  • sloc: cpp: 267,090; ansic: 152,211; sh: 35,196; python: 2,630; makefile: 2,220; perl: 1,690; pascal: 1,218; lisp: 184; csh: 117; xml: 38; asm: 32; exp: 4
file content (73 lines) | stat: -rw-r--r-- 2,050 bytes parent folder | download | duplicates (3)
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
/*
 *  Copyright (C) 2013 Sourcefire, Inc.
 *
 *  Authors: David Raynor <draynor@sourcefire.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 *
 *  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., 51 Franklin Street, Fifth Floor, Boston,
 *  MA 02110-1301, USA.
 */

#ifndef CLAM_ADC_H
#define CLAM_ADC_H

struct adc_stream {
    uint8_t *next_in;
    size_t avail_in;
    size_t total_in;

    uint8_t *next_out;
    size_t avail_out;
    size_t total_out;

    /* internals */
    uint8_t *buffer;
    uint8_t *curr;

    uint32_t buffered;
    uint16_t state;
    uint16_t length;
    uint32_t offset;
};
typedef struct adc_stream adc_stream;

#define ADC_BUFF_SIZE 65536

#define    ADC_MEM_ERROR -1
#define    ADC_DATA_ERROR -2
#define    ADC_IO_ERROR -3
#define    ADC_OK 0
#define    ADC_STREAM_END 1

enum adc_state {
    ADC_STATE_UNINIT = 0,
    ADC_STATE_GETTYPE = 1,
    ADC_STATE_RAWDATA = 2,
    ADC_STATE_SHORTOP = 3,
    ADC_STATE_LONGOP2 = 4,
    ADC_STATE_LONGOP1 = 5,
    ADC_STATE_SHORTLOOK = 6,
    ADC_STATE_LONGLOOK = 7
};

/* Compression phrases
 * store phrase - 1 byte header + data, first byte 0x80-0xFF, max length 0x80 (7 bits + 1), no offset
 * short phrase - 2 byte header + data, first byte 0x00-0x3F, max length 0x12 (4 bits + 3), max offset 0x3FF (10 bits)
 * long phrase  - 3 byte header + data, first byte 0x40-0x7F, max length 0x43 (6 bits + 4), max offset 0xFFFF (16 bits)
 */

int adc_decompressInit(adc_stream *strm);
int adc_decompress(adc_stream *strm);
int adc_decompressEnd(adc_stream *strm);

#endif