Annotation of src/usr.bin/compress/compress.h, Revision 1.16
1.16 ! jmc 1: /* $OpenBSD: compress.h,v 1.15 2022/10/22 14:41:27 millert Exp $ */
1.1 mickey 2:
3: /*
4: * Copyright (c) 1997 Michael Shalayeff
5: * All rights reserved.
6: *
7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
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: *
1.3 mickey 16: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1.1 mickey 18: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26: * SUCH DAMAGE.
27: *
28: */
29:
1.8 otto 30: #include <sys/stat.h>
31:
1.6 millert 32: struct z_info {
33: u_int32_t mtime; /* timestamp */
34: u_int32_t crc; /* crc */
35: u_int32_t hlen; /* header length */
36: u_int64_t total_in; /* # bytes in */
37: u_int64_t total_out; /* # bytes out */
38: };
39:
1.3 mickey 40: /*
1.16 ! jmc 41: * making it any bigger does not affect performance very much.
1.3 mickey 42: * actually this value is just a little bit better than 8192.
43: */
1.1 mickey 44: #define Z_BUFSIZE 16384
1.9 sobrado 45:
1.10 sobrado 46: enum program_mode {
1.11 sobrado 47: MODE_COMP,
48: MODE_DECOMP,
49: MODE_CAT
1.14 mortimer 50: };
1.1 mickey 51:
1.6 millert 52: /*
53: * exit codes for compress
54: */
55: #define SUCCESS 0
56: #define FAILURE 1
57: #define WARNING 2
58:
1.7 tedu 59: extern char null_magic[];
1.3 mickey 60:
1.13 tedu 61: extern void *z_ropen(int, char *, int);
62: extern void *z_wopen(int, char *, int, u_int32_t);
1.2 millert 63: extern FILE *zopen(const char *, const char *,int);
64: extern int zread(void *, char *, int);
65: extern int zwrite(void *, const char *, int);
1.8 otto 66: extern int z_close(void *, struct z_info *, const char *, struct stat *);
1.6 millert 67:
1.13 tedu 68: extern void *gz_ropen(int, char *, int);
69: extern void *gz_wopen(int, char *, int, u_int32_t);
1.2 millert 70: extern int gz_read(void *, char *, int);
71: extern int gz_write(void *, const char *, int);
1.8 otto 72: extern int gz_close(void *, struct z_info *, const char *, struct stat *);
1.2 millert 73: extern int gz_flush(void *, int);
1.15 millert 74:
75: extern void *zip_ropen(int, char *, int);
76: extern int zip_read(void *, char *, int);
77: extern int zip_close(void *, struct z_info *, const char *, struct stat *);
1.3 mickey 78:
1.13 tedu 79: extern void *null_ropen(int, char *, int);
80: extern void *null_wopen(int, char *, int, u_int32_t);
1.7 tedu 81: extern int null_read(void *, char *, int);
82: extern int null_write(void *, const char *, int);
1.8 otto 83: extern int null_close(void *, struct z_info *, const char *, struct stat *);
1.7 tedu 84: extern int null_flush(void *, int);
1.8 otto 85:
86: extern void setfile(const char *, int, struct stat *);