2
* Interface to libclamunrar
3
* Copyright (C) 2007 Sourcefire, Inc.
4
* Authors: Trog, Torok Edvin, Tomasz Kojm
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.
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.
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.
20
#ifndef __UNRAR_IFACE_H
21
#define __UNRAR_IFACE_H
24
#include "clamav-config.h"
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
32
#ifndef HAVE_ATTRIB_PACKED
33
#define __attribute__(x)
36
#ifdef HAVE_PRAGMA_PACK
40
#ifdef HAVE_PRAGMA_PACK_HPPA
46
#define UNRAR_PASSWD 2
50
typedef struct unrar_comment_header_tag
52
uint16_t head_crc __attribute__ ((packed));
54
uint16_t flags __attribute__ ((packed));
55
uint16_t head_size __attribute__ ((packed));
56
uint16_t unpack_size __attribute__ ((packed));
59
uint16_t comm_crc __attribute__ ((packed));
60
} unrar_comment_header_t;
62
#define UNRAR_MAIN_HEADER_TAG_LEN 13
63
typedef struct unrar_main_header_tag
65
uint16_t head_crc __attribute__ ((packed));
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;
73
typedef struct unrar_file_header_tag
75
uint16_t head_crc __attribute__ ((packed));
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));
82
uint32_t file_crc __attribute__ ((packed));
83
uint32_t file_time __attribute__ ((packed));
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));
95
#ifdef HAVE_PRAGMA_PACK
99
#ifdef HAVE_PRAGMA_PATCH_HPPA
103
typedef struct unrar_metadata_tag
106
uint64_t unpack_size;
108
struct unrar_metadata_tag *next;
110
unsigned int encrypted;
114
typedef struct unrar_state_tag {
115
unrar_fileheader_t *file_header;
116
unrar_metadata_t *metadata;
117
unrar_metadata_t *metadata_tail;
119
unrar_main_header_t *main_hdr;
121
unsigned long file_count;
122
uint64_t maxfilesize;
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);