2 * Copyright (C) 2001-2003 Hewlett-Packard Co.
3 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
5 * This file is part of the ELILO, the EFI Linux boot loader.
7 * ELILO is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * ELILO is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with ELILO; see the file COPYING. If not, write to the Free
19 * Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 * Please check out the elilo.txt for complete documentation on how
23 * to use this program.
29 int gunzip_image(memdesc_t *);
30 int gunzip_kernel(fops_fd_t, kdesc_t *);
33 #define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
34 #define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
35 #define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
36 #define ORIG_NAME 0x08 /* bit 3 set: original file name present */
37 #define COMMENT 0x10 /* bit 4 set: file comment present */
38 #define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
39 #define RESERVED 0xC0 /* bit 6,7: reserved */
42 * check for valid gzip signature
44 * 0 : valid gzip archive
45 * -1: invalid gzip archive
48 gzip_probe(unsigned char *buf, unsigned long size)
50 if (size < 4) return -1;
53 ((buf[1] != 0213) && (buf[1] != 0236))) return -1;
55 /* We only support method #8, DEFLATED */
56 if (buf[2] != 8) return -1;
58 if ((buf[3] & ENCRYPTED) != 0) return -1;
60 if ((buf[3] & CONTINUATION) != 0) return -1;
62 if ((buf[3] & RESERVED) != 0) return -1;
67 #endif /* __GZIP_H__ */