24fd05e1 |
/* |
9518ee06 |
* Copyright (C) 2007-2008 Sourcefire, Inc.
* |
2023340a |
* Authors: Tomasz Kojm |
24fd05e1 |
*
* 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 __CAB_H
#define __CAB_H
#include <sys/types.h>
#include "cltypes.h"
|
6cb9a52c |
#define CAB_BLOCKMAX 65535 |
24fd05e1 |
#define CAB_INPUTMAX (CAB_BLOCKMAX + 6144)
struct cab_archive { |
9518ee06 |
struct cab_folder *folders, *actfol; |
b5231f5f |
struct cab_file *files; |
9518ee06 |
struct cab_state *state; |
24fd05e1 |
uint32_t length;
uint16_t nfolders;
uint16_t nfiles;
uint16_t flags;
uint16_t reshdr;
uint8_t resdata;
};
struct cab_state {
unsigned char *pt, *end; |
b5231f5f |
void *stream; |
24fd05e1 |
unsigned char block[CAB_INPUTMAX];
uint16_t blklen;
uint16_t outlen;
uint16_t blknum; |
9518ee06 |
uint16_t cmethod; |
24fd05e1 |
};
struct cab_file {
off_t offset;
char *name; |
b5231f5f |
uint32_t length; |
24fd05e1 |
int error; |
72ce4b70 |
int lread; |
24fd05e1 |
int fd; |
5a5e6312 |
int ofd; |
24fd05e1 |
struct cab_folder *folder;
struct cab_file *next;
struct cab_archive *cab; |
094104a7 |
uint16_t attribs; |
8df99a92 |
uint64_t max_size, written_size; |
24fd05e1 |
};
struct cab_folder {
struct cab_archive *cab;
off_t offset;
struct cab_folder *next; |
b5231f5f |
uint16_t cmethod;
uint16_t nblocks; |
24fd05e1 |
};
int cab_open(int fd, off_t offset, struct cab_archive *cab); |
5a5e6312 |
int cab_extract(struct cab_file *file, const char *name); |
24fd05e1 |
void cab_free(struct cab_archive *cab);
#endif |