1 /* $FreeBSD: src/usr.sbin/pkg_install/sign/gzip.h,v 1.1.2.2 2001/05/17 12:33:39 sobomax Exp $ */
2 /* $DragonFly: src/usr.sbin/pkg_install/sign/Attic/gzip.h,v 1.2 2003/06/17 04:29:59 dillon Exp $ */
3 /* $OpenBSD: gzip.h,v 1.2 1999/10/04 21:46:28 espie Exp $ */
5 * Copyright (c) 1999 Marc Espie.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Marc Espie for the OpenBSD
20 * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
24 * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #define GZIP_MAGIC0 '\037'
34 #define GZIP_MAGIC1 '\213'
36 #define CONTINUATION 0x02
37 #define EXTRA_FIELD 0x04
40 * Meaningful fields in a gzip header, see gzip proper for details.
41 * This structure should not be fiddled with outside of gzip_read_header
42 * and gzip_write_header
44 struct mygzip_header {
49 /* remaining extra, after know signs have been read */
50 unsigned int remaining;
56 typedef unsigned char SIGNTAG[8];
58 /* stack of signatures */
64 struct signature *next;
67 /* returns from gzip_read_header */
68 #define GZIP_UNSIGNED 0 /* gzip file, no signature */
69 #define GZIP_SIGNED 1 /* gzip file, signature parsed ok */
70 #define GZIP_NOT_GZIP 2 /* not a proper gzip file */
71 #define GZIP_NOT_PGPSIGNED 3 /* gzip file, unknown extension */
72 extern int gzip_read_header __P((FILE *f, /*@out@*/struct mygzip_header *h, \
73 /*@null@*/struct signature **sign));
74 /* gzip_write_header returns 1 for success */
75 extern int gzip_write_header __P((FILE *f, const struct mygzip_header *h, \
76 /*@null@*/struct signature *sign));
78 * Writing header to memory. Returns size needed, or 0 if buffer too small
79 * buffer must be at least 14 characters
81 extern int gzip_copy_header __P((const struct mygzip_header *h, \
82 /*@null@*/struct signature *sign, \
83 void (*add)(void *, const char *, size_t), void *data));
85 extern void free_signature __P((/*@null@*/struct signature *sign));
86 extern void sign_fill_tag __P((struct signature *sign));
93 #define pgptag (known_tags[TAG_PGP])
94 #define sha1tag (known_tags[TAG_SHA1])
95 #define x509tag (known_tags[TAG_X509])
96 extern SIGNTAG known_tags[KNOWN_TAGS];