~ubuntu-branches/ubuntu/feisty/clamav/feisty

« back to all changes in this revision

Viewing changes to libclamunrar_iface/unrar_iface.h

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-02-20 10:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20070220103344-zgcu2psnx9d98fpa
Tags: upstream-0.90
ImportĀ upstreamĀ versionĀ 0.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  Interface to libclamunrar
3
 
 *  Copyright (C) 2007 Sourcefire, Inc.
4
 
 *  Authors: Trog, Torok Edvin, Tomasz Kojm
5
 
 *
6
 
 *  This library is free software; you can redistribute it and/or
7
 
 *  modify it under the terms of the GNU Lesser General Public
8
 
 *  License version 2.1 as published by the Free Software Foundation.
9
 
 *
10
 
 *  This library is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 
 *  Lesser General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU Lesser General Public
16
 
 *  License along with this library; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
18
 
 */
19
 
 
20
 
#ifndef __UNRAR_IFACE_H
21
 
#define __UNRAR_IFACE_H
22
 
 
23
 
#if HAVE_CONFIG_H
24
 
#include "clamav-config.h"
25
 
#endif
26
 
 
27
 
#define unrar_open libclamunrar_iface_LTX_unrar_open
28
 
#define unrar_extract_next_prepare libclamunrar_iface_LTX_unrar_extract_next_prepare
29
 
#define unrar_extract_next libclamunrar_iface_LTX_unrar_extract_next
30
 
#define unrar_close libclamunrar_iface_LTX_unrar_close
31
 
 
32
 
#ifndef HAVE_ATTRIB_PACKED
33
 
#define __attribute__(x)
34
 
#endif
35
 
 
36
 
#ifdef HAVE_PRAGMA_PACK
37
 
#pragma pack(1)
38
 
#endif
39
 
 
40
 
#ifdef HAVE_PRAGMA_PACK_HPPA
41
 
#pragma pack 1
42
 
#endif
43
 
 
44
 
#define UNRAR_OK         0
45
 
#define UNRAR_BREAK      1
46
 
#define UNRAR_PASSWD     2
47
 
#define UNRAR_EMEM      -1
48
 
#define UNRAR_ERR       -2
49
 
 
50
 
typedef struct unrar_comment_header_tag
51
 
{
52
 
    uint16_t head_crc __attribute__ ((packed));
53
 
    uint8_t head_type;
54
 
    uint16_t flags __attribute__ ((packed));
55
 
    uint16_t head_size __attribute__ ((packed));
56
 
    uint16_t unpack_size __attribute__ ((packed));
57
 
    uint8_t unpack_ver;
58
 
    uint8_t method;
59
 
    uint16_t comm_crc __attribute__ ((packed));
60
 
} unrar_comment_header_t;
61
 
 
62
 
#define UNRAR_MAIN_HEADER_TAG_LEN 13
63
 
typedef struct unrar_main_header_tag
64
 
{
65
 
    uint16_t head_crc __attribute__ ((packed));
66
 
    uint8_t head_type;
67
 
    uint16_t flags __attribute__ ((packed));
68
 
    uint16_t head_size __attribute__ ((packed));
69
 
    uint16_t highposav __attribute__ ((packed));
70
 
    uint32_t posav __attribute__ ((packed));
71
 
} unrar_main_header_t;
72
 
 
73
 
typedef struct unrar_file_header_tag
74
 
{
75
 
    uint16_t head_crc __attribute__ ((packed));
76
 
    uint8_t head_type;
77
 
    uint16_t flags __attribute__ ((packed));
78
 
    uint16_t head_size __attribute__ ((packed));
79
 
    uint32_t pack_size __attribute__ ((packed));
80
 
    uint32_t unpack_size __attribute__ ((packed));
81
 
    uint8_t host_os;
82
 
    uint32_t file_crc __attribute__ ((packed));
83
 
    uint32_t file_time __attribute__ ((packed));
84
 
    uint8_t unpack_ver;
85
 
    uint8_t method;
86
 
    uint16_t name_size __attribute__ ((packed));
87
 
    uint32_t file_attr __attribute__ ((packed));
88
 
    uint32_t high_pack_size __attribute__ ((packed));   /* optional */
89
 
    uint32_t high_unpack_size __attribute__ ((packed)); /* optional */
90
 
    unsigned char *filename __attribute__ ((packed));
91
 
    off_t start_offset __attribute__ ((packed));
92
 
    off_t next_offset __attribute__ ((packed));
93
 
} unrar_fileheader_t;
94
 
 
95
 
#ifdef HAVE_PRAGMA_PACK
96
 
#pragma pack()
97
 
#endif
98
 
 
99
 
#ifdef HAVE_PRAGMA_PATCH_HPPA
100
 
#pragma pack
101
 
#endif
102
 
 
103
 
typedef struct unrar_metadata_tag
104
 
{
105
 
    uint64_t pack_size;
106
 
    uint64_t unpack_size;
107
 
    char *filename;
108
 
    struct unrar_metadata_tag *next;
109
 
    uint32_t crc;
110
 
    unsigned int encrypted;
111
 
    uint8_t method;
112
 
} unrar_metadata_t;
113
 
 
114
 
typedef struct unrar_state_tag {
115
 
    unrar_fileheader_t *file_header;
116
 
    unrar_metadata_t *metadata;
117
 
    unrar_metadata_t *metadata_tail;
118
 
    void *unpack_data;
119
 
    unrar_main_header_t *main_hdr;
120
 
    char *comment_dir;
121
 
    unsigned long file_count;
122
 
    uint64_t maxfilesize;
123
 
    int fd, ofd;
124
 
    char filename[1024];
125
 
} unrar_state_t;
126
 
 
127
 
 
128
 
int unrar_open(int fd, const char *dirname, unrar_state_t *state);
129
 
int unrar_extract_next_prepare(unrar_state_t *state, const char *dirname);
130
 
int unrar_extract_next(unrar_state_t *state, const char *dirname);
131
 
void unrar_close(unrar_state_t *state);
132
 
 
133
 
#endif