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 ***********************************************************************/
28 /******************************************************************************/
29 /* stand-alone unpacker */
30 /******************************************************************************/
31 typedef struct haunp_s
*haunp_t
;
33 /* <0: error; 0: EOF; >0: bytes read (can be less that buf_len) */
34 /* buf_len can never be negative or zero; it will not be more that INT_MAX/2-1 either */
35 typedef int (*haunp_bread_fn_t
) (void *buf
, int buf_len
, void *udata
);
38 /* return NULL on error (out of memory) */
39 extern haunp_t
haunp_open_io (haunp_bread_fn_t reader
, void *udata
);
40 extern haunp_t
haunp_open_buf (const void *buf
, int buf_len
); /* buf MUST be alive until haunp_close() called! */
42 /* return 0 if ok or -1 on error */
43 extern int haunp_reset_io (haunp_t hup
, haunp_bread_fn_t reader
, void *udata
);
44 extern int haunp_reset_buf (haunp_t hup
, const void *buf
, int buf_len
); /* buf MUST be alive until haunp_close() called! */
46 extern int haunp_close (haunp_t hup
);
48 /* return number of bytes read (<len: end of data) or -1 on error */
49 extern int haunp_read (haunp_t hup
, void *buf
, int len
);