aboutsummaryrefslogtreecommitdiff
path: root/inflate.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2023-04-14 01:42:03 -0700
committerMark Adler <madler@alumni.caltech.edu>2023-04-15 21:17:31 -0700
commite9d5486e6635141f589e110fd789648aa08e9544 (patch)
treea78b9ccd92b05af7cd5776b688d9c3eb3a81a40a /inflate.c
parent5799c14c8526bf1aaa130c021982f831d155b46d (diff)
downloadzlib-e9d5486e6635141f589e110fd789648aa08e9544.tar.gz
zlib-e9d5486e6635141f589e110fd789648aa08e9544.tar.bz2
zlib-e9d5486e6635141f589e110fd789648aa08e9544.zip
Remove K&R function definitions from zlib.
C2X has removed K&R definitions from the C function syntax. Though the standard has not yet been approved, some high-profile compilers are now issuing warnings when such definitions are encountered.
Diffstat (limited to 'inflate.c')
-rw-r--r--inflate.c127
1 files changed, 28 insertions, 99 deletions
diff --git a/inflate.c b/inflate.c
index ef60267..b0757a9 100644
--- a/inflate.c
+++ b/inflate.c
@@ -91,20 +91,7 @@
91# endif 91# endif
92#endif 92#endif
93 93
94/* function prototypes */ 94local int inflateStateCheck(z_streamp strm) {
95local int inflateStateCheck OF((z_streamp strm));
96local void fixedtables OF((struct inflate_state FAR *state));
97local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
98 unsigned copy));
99#ifdef BUILDFIXED
100 void makefixed OF((void));
101#endif
102local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
103 unsigned len));
104
105local int inflateStateCheck(strm)
106z_streamp strm;
107{
108 struct inflate_state FAR *state; 95 struct inflate_state FAR *state;
109 if (strm == Z_NULL || 96 if (strm == Z_NULL ||
110 strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) 97 strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
@@ -116,9 +103,7 @@ z_streamp strm;
116 return 0; 103 return 0;
117} 104}
118 105
119int ZEXPORT inflateResetKeep(strm) 106int ZEXPORT inflateResetKeep(z_streamp strm) {
120z_streamp strm;
121{
122 struct inflate_state FAR *state; 107 struct inflate_state FAR *state;
123 108
124 if (inflateStateCheck(strm)) return Z_STREAM_ERROR; 109 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
@@ -142,9 +127,7 @@ z_streamp strm;
142 return Z_OK; 127 return Z_OK;
143} 128}
144 129
145int ZEXPORT inflateReset(strm) 130int ZEXPORT inflateReset(z_streamp strm) {
146z_streamp strm;
147{
148 struct inflate_state FAR *state; 131 struct inflate_state FAR *state;
149 132
150 if (inflateStateCheck(strm)) return Z_STREAM_ERROR; 133 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
@@ -155,10 +138,7 @@ z_streamp strm;
155 return inflateResetKeep(strm); 138 return inflateResetKeep(strm);
156} 139}
157 140
158int ZEXPORT inflateReset2(strm, windowBits) 141int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
159z_streamp strm;
160int windowBits;
161{
162 int wrap; 142 int wrap;
163 struct inflate_state FAR *state; 143 struct inflate_state FAR *state;
164 144
@@ -195,12 +175,8 @@ int windowBits;
195 return inflateReset(strm); 175 return inflateReset(strm);
196} 176}
197 177
198int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) 178int ZEXPORT inflateInit2_(z_streamp strm, int windowBits,
199z_streamp strm; 179 const char *version, int stream_size) {
200int windowBits;
201const char *version;
202int stream_size;
203{
204 int ret; 180 int ret;
205 struct inflate_state FAR *state; 181 struct inflate_state FAR *state;
206 182
@@ -239,19 +215,12 @@ int stream_size;
239 return ret; 215 return ret;
240} 216}
241 217
242int ZEXPORT inflateInit_(strm, version, stream_size) 218int ZEXPORT inflateInit_(z_streamp strm, const char *version,
243z_streamp strm; 219 int stream_size) {
244const char *version;
245int stream_size;
246{
247 return inflateInit2_(strm, DEF_WBITS, version, stream_size); 220 return inflateInit2_(strm, DEF_WBITS, version, stream_size);
248} 221}
249 222
250int ZEXPORT inflatePrime(strm, bits, value) 223int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) {
251z_streamp strm;
252int bits;
253int value;
254{
255 struct inflate_state FAR *state; 224 struct inflate_state FAR *state;
256 225
257 if (inflateStateCheck(strm)) return Z_STREAM_ERROR; 226 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
@@ -280,9 +249,7 @@ int value;
280 used for threaded applications, since the rewriting of the tables and virgin 249 used for threaded applications, since the rewriting of the tables and virgin
281 may not be thread-safe. 250 may not be thread-safe.
282 */ 251 */
283local void fixedtables(state) 252local void fixedtables(struct inflate_state FAR *state) {
284struct inflate_state FAR *state;
285{
286#ifdef BUILDFIXED 253#ifdef BUILDFIXED
287 static int virgin = 1; 254 static int virgin = 1;
288 static code *lenfix, *distfix; 255 static code *lenfix, *distfix;
@@ -344,7 +311,7 @@ struct inflate_state FAR *state;
344 311
345 a.out > inffixed.h 312 a.out > inffixed.h
346 */ 313 */
347void makefixed() 314void makefixed(void)
348{ 315{
349 unsigned low, size; 316 unsigned low, size;
350 struct inflate_state state; 317 struct inflate_state state;
@@ -398,11 +365,7 @@ void makefixed()
398 output will fall in the output data, making match copies simpler and faster. 365 output will fall in the output data, making match copies simpler and faster.
399 The advantage may be dependent on the size of the processor's data caches. 366 The advantage may be dependent on the size of the processor's data caches.
400 */ 367 */
401local int updatewindow(strm, end, copy) 368local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
402z_streamp strm;
403const Bytef *end;
404unsigned copy;
405{
406 struct inflate_state FAR *state; 369 struct inflate_state FAR *state;
407 unsigned dist; 370 unsigned dist;
408 371
@@ -624,10 +587,7 @@ unsigned copy;
624 will return Z_BUF_ERROR if it has not reached the end of the stream. 587 will return Z_BUF_ERROR if it has not reached the end of the stream.
625 */ 588 */
626 589
627int ZEXPORT inflate(strm, flush) 590int ZEXPORT inflate(z_streamp strm, int flush) {
628z_streamp strm;
629int flush;
630{
631 struct inflate_state FAR *state; 591 struct inflate_state FAR *state;
632 z_const unsigned char FAR *next; /* next input */ 592 z_const unsigned char FAR *next; /* next input */
633 unsigned char FAR *put; /* next output */ 593 unsigned char FAR *put; /* next output */
@@ -1303,9 +1263,7 @@ int flush;
1303 return ret; 1263 return ret;
1304} 1264}
1305 1265
1306int ZEXPORT inflateEnd(strm) 1266int ZEXPORT inflateEnd(z_streamp strm) {
1307z_streamp strm;
1308{
1309 struct inflate_state FAR *state; 1267 struct inflate_state FAR *state;
1310 if (inflateStateCheck(strm)) 1268 if (inflateStateCheck(strm))
1311 return Z_STREAM_ERROR; 1269 return Z_STREAM_ERROR;
@@ -1317,11 +1275,8 @@ z_streamp strm;
1317 return Z_OK; 1275 return Z_OK;
1318} 1276}
1319 1277
1320int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) 1278int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary,
1321z_streamp strm; 1279 uInt *dictLength) {
1322Bytef *dictionary;
1323uInt *dictLength;
1324{
1325 struct inflate_state FAR *state; 1280 struct inflate_state FAR *state;
1326 1281
1327 /* check state */ 1282 /* check state */
@@ -1340,11 +1295,8 @@ uInt *dictLength;
1340 return Z_OK; 1295 return Z_OK;
1341} 1296}
1342 1297
1343int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) 1298int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary,
1344z_streamp strm; 1299 uInt dictLength) {
1345const Bytef *dictionary;
1346uInt dictLength;
1347{
1348 struct inflate_state FAR *state; 1300 struct inflate_state FAR *state;
1349 unsigned long dictid; 1301 unsigned long dictid;
1350 int ret; 1302 int ret;
@@ -1375,10 +1327,7 @@ uInt dictLength;
1375 return Z_OK; 1327 return Z_OK;
1376} 1328}
1377 1329
1378int ZEXPORT inflateGetHeader(strm, head) 1330int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) {
1379z_streamp strm;
1380gz_headerp head;
1381{
1382 struct inflate_state FAR *state; 1331 struct inflate_state FAR *state;
1383 1332
1384 /* check state */ 1333 /* check state */
@@ -1403,11 +1352,8 @@ gz_headerp head;
1403 called again with more data and the *have state. *have is initialized to 1352 called again with more data and the *have state. *have is initialized to
1404 zero for the first call. 1353 zero for the first call.
1405 */ 1354 */
1406local unsigned syncsearch(have, buf, len) 1355local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf,
1407unsigned FAR *have; 1356 unsigned len) {
1408const unsigned char FAR *buf;
1409unsigned len;
1410{
1411 unsigned got; 1357 unsigned got;
1412 unsigned next; 1358 unsigned next;
1413 1359
@@ -1426,9 +1372,7 @@ unsigned len;
1426 return next; 1372 return next;
1427} 1373}
1428 1374
1429int ZEXPORT inflateSync(strm) 1375int ZEXPORT inflateSync(z_streamp strm) {
1430z_streamp strm;
1431{
1432 unsigned len; /* number of bytes to look at or looked at */ 1376 unsigned len; /* number of bytes to look at or looked at */
1433 int flags; /* temporary to save header status */ 1377 int flags; /* temporary to save header status */
1434 unsigned long in, out; /* temporary to save total_in and total_out */ 1378 unsigned long in, out; /* temporary to save total_in and total_out */
@@ -1484,9 +1428,7 @@ z_streamp strm;
1484 block. When decompressing, PPP checks that at the end of input packet, 1428 block. When decompressing, PPP checks that at the end of input packet,
1485 inflate is waiting for these length bytes. 1429 inflate is waiting for these length bytes.
1486 */ 1430 */
1487int ZEXPORT inflateSyncPoint(strm) 1431int ZEXPORT inflateSyncPoint(z_streamp strm) {
1488z_streamp strm;
1489{
1490 struct inflate_state FAR *state; 1432 struct inflate_state FAR *state;
1491 1433
1492 if (inflateStateCheck(strm)) return Z_STREAM_ERROR; 1434 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
@@ -1494,10 +1436,7 @@ z_streamp strm;
1494 return state->mode == STORED && state->bits == 0; 1436 return state->mode == STORED && state->bits == 0;
1495} 1437}
1496 1438
1497int ZEXPORT inflateCopy(dest, source) 1439int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
1498z_streamp dest;
1499z_streamp source;
1500{
1501 struct inflate_state FAR *state; 1440 struct inflate_state FAR *state;
1502 struct inflate_state FAR *copy; 1441 struct inflate_state FAR *copy;
1503 unsigned char FAR *window; 1442 unsigned char FAR *window;
@@ -1541,10 +1480,7 @@ z_streamp source;
1541 return Z_OK; 1480 return Z_OK;
1542} 1481}
1543 1482
1544int ZEXPORT inflateUndermine(strm, subvert) 1483int ZEXPORT inflateUndermine(z_streamp strm, int subvert) {
1545z_streamp strm;
1546int subvert;
1547{
1548 struct inflate_state FAR *state; 1484 struct inflate_state FAR *state;
1549 1485
1550 if (inflateStateCheck(strm)) return Z_STREAM_ERROR; 1486 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
@@ -1559,10 +1495,7 @@ int subvert;
1559#endif 1495#endif
1560} 1496}
1561 1497
1562int ZEXPORT inflateValidate(strm, check) 1498int ZEXPORT inflateValidate(z_streamp strm, int check) {
1563z_streamp strm;
1564int check;
1565{
1566 struct inflate_state FAR *state; 1499 struct inflate_state FAR *state;
1567 1500
1568 if (inflateStateCheck(strm)) return Z_STREAM_ERROR; 1501 if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
@@ -1574,9 +1507,7 @@ int check;
1574 return Z_OK; 1507 return Z_OK;
1575} 1508}
1576 1509
1577long ZEXPORT inflateMark(strm) 1510long ZEXPORT inflateMark(z_streamp strm) {
1578z_streamp strm;
1579{
1580 struct inflate_state FAR *state; 1511 struct inflate_state FAR *state;
1581 1512
1582 if (inflateStateCheck(strm)) 1513 if (inflateStateCheck(strm))
@@ -1587,9 +1518,7 @@ z_streamp strm;
1587 (state->mode == MATCH ? state->was - state->length : 0)); 1518 (state->mode == MATCH ? state->was - state->length : 0));
1588} 1519}
1589 1520
1590unsigned long ZEXPORT inflateCodesUsed(strm) 1521unsigned long ZEXPORT inflateCodesUsed(z_streamp strm) {
1591z_streamp strm;
1592{
1593 struct inflate_state FAR *state; 1522 struct inflate_state FAR *state;
1594 if (inflateStateCheck(strm)) return (unsigned long)-1; 1523 if (inflateStateCheck(strm)) return (unsigned long)-1;
1595 state = (struct inflate_state FAR *)strm->state; 1524 state = (struct inflate_state FAR *)strm->state;