utils/magic_zlib.h: limit #include <zlib.h> to files that need it

Remove limited use HAVE_ZLIB wrapper API into separate header as
utils.h is used in many places and most source files don't need
to drag in the header file from this external dependency.

Copyright date(s) taken from original source file / git blame.
This commit is contained in:
Darryl L. Miles 2024-10-04 20:07:03 +01:00 committed by R. Timothy Edwards
parent 4a1da7fe7c
commit f88c7a86cb
8 changed files with 46 additions and 16 deletions

View File

@ -44,6 +44,7 @@ static const char rcsid[] __attribute__ ((unused)) ="$Header: /usr/cvsroot/magic
#include "utils/geometry.h"
#include "tiles/tile.h"
#include "utils/utils.h"
#include "utils/magic_zlib.h"
#include "utils/hash.h"
#include "database/database.h"
#include "database/databaseInt.h"

View File

@ -54,6 +54,7 @@ static const char rcsid[] __attribute__ ((unused)) ="$Header: /usr/cvsroot/magic
#include "utils/geometry.h"
#include "tiles/tile.h"
#include "utils/utils.h"
#include "utils/magic_zlib.h"
#include "utils/hash.h"
#include "database/database.h"
#include "database/databaseInt.h"

View File

@ -37,6 +37,7 @@ static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magi
#include "utils/main.h"
#include "commands/commands.h"
#include "utils/utils.h"
#include "utils/magic_zlib.h"
#include "textio/textio.h"
#include "drc/drc.h"
#include "graphics/graphics.h"

View File

@ -60,6 +60,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "utils/geometry.h"
#include "tiles/tile.h"
#include "utils/utils.h"
#include "utils/magic_zlib.h"
#include "utils/hash.h"
#include "database/database.h"
#include "database/databaseInt.h"

View File

@ -23,6 +23,7 @@
#include "database/database.h"
#include "windows/windows.h"
#include "utils/malloc.h"
#include "utils/magic_zlib.h"
/* C99 compat */
#include "textio/textio.h"

39
utils/magic_zlib.h Normal file
View File

@ -0,0 +1,39 @@
/* zlib.h --
*
* Routines relating to the external dependency zlib
*
* *********************************************************************
* * Copyright (C) 2022, 2024 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*
* rcsid="$Header"
*/
#ifndef _MAGIC__UTILS__MAGIC_ZLIB_H
#define _MAGIC__UTILS__MAGIC_ZLIB_H
#ifdef HAVE_ZLIB
#include <zlib.h>
extern gzFile PaZOpen(const char *file, const char *mode, const char *ext, const char *path, const char *library,
char **pRealName);
extern gzFile PaLockZOpen(const char *file, const char *mode, const char *ext, const char *path, const char *library,
char **pRealName, bool *is_locked, int *fdp);
extern char *PaCheckCompressed(const char *filename);
#ifdef FILE_LOCKS
extern gzFile flock_zopen();
#endif
#endif
#endif /* _MAGIC__UTILS__MAGIC_ZLIB_H */

View File

@ -40,6 +40,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "utils/hash.h"
#include "utils/malloc.h"
#include "utils/utils.h"
#include "utils/magic_zlib.h"
/* Library routines: */

View File

@ -21,12 +21,8 @@
#ifndef _UTILS_H
#define _UTILS_H 1
#ifdef HAVE_ZLIB
#include <zlib.h>
#endif
#include "utils/tech.h"
#include "utils/magic.h"
#include "utils/tech.h"
/*
* Cast second argument to LookupStruct() to (LookupTable *) to
@ -76,21 +72,10 @@ extern void SetNoisyInt(int *parm, const char *valueS, FILE *file);
extern void SetNoisyDI(dlong *parm, const char *valueS, FILE *file);
extern bool ParsSplit();
#ifdef HAVE_ZLIB
extern gzFile PaZOpen(const char *file, const char *mode, const char *ext, const char *path, const char *library,
char **pRealName);
extern gzFile PaLockZOpen(const char *file, const char *mode, const char *ext, const char *path, const char *library,
char **pRealName, bool *is_locked, int *fdp);
extern char *PaCheckCompressed(const char *filename);
#endif
extern int SetNoisyBool(bool *parm, const char *valueS, FILE *file);
#ifdef FILE_LOCKS
extern FILE *flock_open();
#ifdef HAVE_ZLIB
extern gzFile flock_zopen();
#endif
#endif
/* The following macro takes an integer and returns another integer that