13398d407f9a5d7bcb3eb5e670ab2585a13d6082
[oweals/opkg-lede.git] / libbb / gzip.h
1 /*
2  *  Copyright (C) 2016 Jo-Philipp Wich <jo@mein.io>
3  *
4  *  Zlib decrompression utility routines.
5  *
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.
10  *
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 Library General Public License for more details.
15  *
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20
21 #include <stdio.h>
22 #include <signal.h>
23 #include <pthread.h>
24
25 struct gzip_handle {
26         FILE *file;
27         struct gzip_handle *gzip;
28
29         pid_t pid;
30         int rfd, wfd;
31         struct sigaction pipe_sa;
32         pthread_t thread;
33 };
34
35 int gzip_exec(struct gzip_handle *zh, const char *filename);
36 ssize_t gzip_read(struct gzip_handle *zh, char *buf, ssize_t len);
37 ssize_t gzip_copy(struct gzip_handle *zh, FILE * out, ssize_t len);
38 int gzip_close(struct gzip_handle *zh);
39 FILE *gzip_fdopen(struct gzip_handle *zh, const char *filename);
40
41 #define gzip_seek(zh, len) gzip_copy(zh, NULL, len)