Skip to content

Commit ce12c5c

Browse files
committed
Make a noble effort at setting OS_CODE correctly.
This updates the OS_CODE determination at compile time to match as closely as possible the operating system mappings documented in the PKWare APPNOTE.TXT version 6.3.4, section 4.4.2.2. That byte in the gzip header is used by nobody for anything, as far as I can tell. However we might as well try to set it appropriately.
1 parent b516b4b commit ce12c5c

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

zutil.h

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,28 +98,38 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
9898
#endif
9999

100100
#ifdef AMIGA
101-
# define OS_CODE 0x01
101+
# define OS_CODE 1
102102
#endif
103103

104104
#if defined(VAXC) || defined(VMS)
105-
# define OS_CODE 0x02
105+
# define OS_CODE 2
106106
# define F_OPEN(name, mode) \
107107
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
108108
#endif
109109

110+
#ifdef __370__
111+
# if __TARGET_LIB__ < 0x20000000
112+
# define OS_CODE 4
113+
# elif __TARGET_LIB__ < 0x40000000
114+
# define OS_CODE 11
115+
# else
116+
# define OS_CODE 8
117+
# endif
118+
#endif
119+
110120
#if defined(ATARI) || defined(atarist)
111-
# define OS_CODE 0x05
121+
# define OS_CODE 5
112122
#endif
113123

114124
#ifdef OS2
115-
# define OS_CODE 0x06
125+
# define OS_CODE 6
116126
# if defined(M_I86) && !defined(Z_SOLO)
117127
# include <malloc.h>
118128
# endif
119129
#endif
120130

121131
#if defined(MACOS) || defined(TARGET_OS_MAC)
122-
# define OS_CODE 0x07
132+
# define OS_CODE 7
123133
# ifndef Z_SOLO
124134
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
125135
# include <unix.h> /* for fdopen */
@@ -131,18 +141,24 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
131141
# endif
132142
#endif
133143

134-
#ifdef TOPS20
135-
# define OS_CODE 0x0a
144+
#ifdef __acorn
145+
# define OS_CODE 13
136146
#endif
137147

138-
#ifdef WIN32
139-
# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
140-
# define OS_CODE 0x0b
141-
# endif
148+
#if defined(WIN32) && !defined(__CYGWIN__)
149+
# define OS_CODE 10
150+
#endif
151+
152+
#ifdef _BEOS_
153+
# define OS_CODE 16
154+
#endif
155+
156+
#ifdef __TOS_OS400__
157+
# define OS_CODE 18
142158
#endif
143159

144-
#ifdef __50SERIES /* Prime/PRIMOS */
145-
# define OS_CODE 0x0f
160+
#ifdef __APPLE__
161+
# define OS_CODE 19
146162
#endif
147163

148164
#if defined(_BEOS_) || defined(RISCOS)
@@ -177,7 +193,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
177193
/* common defaults */
178194

179195
#ifndef OS_CODE
180-
# define OS_CODE 0x03 /* assume Unix */
196+
# define OS_CODE 3 /* assume Unix */
181197
#endif
182198

183199
#ifndef F_OPEN

0 commit comments

Comments
 (0)