1 /***********************************************************************
2 * This file is part of HA, a general purpose file archiver.
3 * Copyright (C) 1995 Harri Hirvola
4 * Modified by Ketmar // Invisible Vector
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 ***********************************************************************/
23 /* define this to disable unpacker */
24 /*#define LIBHA_DISABLE_UNPACKER*/
26 /* define this to disable CRC module */
27 /*#define LIBHA_DISABLE_CRC*/
34 /******************************************************************************/
39 LIBHA_ERR_BAD_DATA
= -3
43 /******************************************************************************/
44 typedef struct libha_io_s
{
45 int (*bread
) (void *buf
, int buf_len
, void *udata
); /* return number of bytes read; 0: EOF; <0: error; can be less than buf_len */
46 int (*bwrite
) (const void *buf
, int buf_len
, void *udata
); /* result != buf_len: error */
50 /******************************************************************************/
51 typedef struct libha_s
*libha_t
;
54 extern libha_t
libha_alloc (const libha_io_t
*iot
, void *udata
);
55 extern void libha_free (libha_t asc
);
57 extern const libha_io_t
*libha_get_iot (libha_t asc
);
58 extern int libha_set_iot (libha_t asc
, const libha_io_t
*iot
); /* <0: error; 0: ok */
60 extern void *libha_get_udata (libha_t asc
);
61 extern int libha_set_udata (libha_t asc
, void *udata
); /* <0: error; 0: ok */
63 /* you need to set i/o structure before calling pack or unpack */
64 extern int libha_pack (libha_t asc
); /* LIBHA_ERR_xxx */
65 #ifndef LIBHA_DISABLE_UNPACKER
66 extern int libha_unpack (libha_t asc
); /* LIBHA_ERR_xxx */
70 /******************************************************************************/
71 /* poly: 0xedb88320L: ISO 3309, ITU-T V.42 */
72 /* unsigned int should be at least 32 bit */
73 #ifndef LIBHA_DISABLE_CRC
74 extern unsigned int libha_crc32 (const void *src
, int len
);
75 extern unsigned int libha_crc32_begin (void);
76 extern unsigned int libha_crc32_end (unsigned int crc
);
77 extern unsigned int libha_crc32_part (unsigned int crc
, const void *src
, int len
);