File: decompress.h

package info (click to toggle)
cdebootstrap 0.7.9
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie, trixie-proposed-updates
  • size: 412 kB
  • sloc: ansic: 3,557; makefile: 232; perl: 118; sh: 87
file content (72 lines) | stat: -rw-r--r-- 2,265 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * decompress.h
 *
 * Copyright (C) 2014-2015 Bastian Blank <waldi@debian.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef DECOMPRESS_H
#define DECOMPRESS_H

#include <stdio.h>
#include <unistd.h>

struct decompress_bz;
struct decompress_gz;
struct decompress_xz;
struct decompress_null;

struct decompress_bz *decompress_bz_new (int fd, size_t len);
struct decompress_gz *decompress_gz_new (int fd, size_t len);
struct decompress_xz *decompress_xz_new (int fd, size_t len);
struct decompress_null *decompress_null_new (int fd, size_t len);

void decompress_bz_free (struct decompress_bz *);
void decompress_gz_free (struct decompress_gz *);
void decompress_xz_free (struct decompress_xz *);
void decompress_null_free (struct decompress_null *);

ssize_t decompress_bz (struct decompress_bz *, int fd);
ssize_t decompress_gz (struct decompress_gz *, int fd);
ssize_t decompress_xz (struct decompress_xz *, int fd);
ssize_t decompress_null (struct decompress_null *, int fd);

static inline void decompress_bz_handler (FILE *f, void *c)
{
  ssize_t r = decompress_bz (c, fileno (f));
  if (r <= 0)
    close (fileno (f));
}
static inline void decompress_gz_handler (FILE *f, void *c)
{
  ssize_t r = decompress_gz (c, fileno (f));
  if (r <= 0)
    close (fileno (f));
}
static inline void decompress_xz_handler (FILE *f, void *c)
{
  ssize_t r = decompress_xz (c, fileno (f));
  if (r <= 0)
    close (fileno (f));
}
static inline void decompress_null_handler (FILE *f, void *c)
{
  ssize_t r = decompress_null (c, fileno (f));
  if (r <= 0)
    close (fileno (f));
}

#endif