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