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 CRC module */
24 /*#define LIBHAUNP_DISABLE_CRC*/
31 /******************************************************************************/
32 /* stand-alone unpacker */
33 /******************************************************************************/
34 typedef struct haunp_s
*haunp_t
;
36 /* <0: error; 0: EOF; >0: bytes read (can be less that buf_len) */
37 /* buf_len can never be negative or zero; it will not be more that INT_MAX/2-1 either */
38 typedef int (*haunp_bread_fn_t
) (void *buf
, int buf_len
, void *udata
);
41 /* return NULL on error (out of memory) */
42 extern haunp_t
haunp_open_io (haunp_bread_fn_t reader
, void *udata
);
43 extern haunp_t
haunp_open_buf (const void *buf
, int buf_len
); /* buf MUST be alive until haunp_close() called! */
45 /* return 0 if ok or -1 on error */
46 extern int haunp_reset_io (haunp_t hup
, haunp_bread_fn_t reader
, void *udata
);
47 extern int haunp_reset_buf (haunp_t hup
, const void *buf
, int buf_len
); /* buf MUST be alive until haunp_close() called! */
49 extern int haunp_close (haunp_t hup
);
51 /* return number of bytes read (<len: end of data) or -1 on error */
52 extern int haunp_read (haunp_t hup
, void *buf
, int len
);
54 /******************************************************************************/
55 /* poly: 0xedb88320L: ISO 3309, ITU-T V.42 */
56 #ifndef LIBHAUNP_DISABLE_CRC
57 extern unsigned int haunp_crc32 (const void *src
, int len
);
58 extern unsigned int haunp_crc32_begin (void);
59 extern unsigned int haunp_crc32_end (unsigned int crc
);
60 extern unsigned int haunp_crc32_part (unsigned int crc
, const void *src
, int len
);