From b3e5e3924d44e2820e60d7d2b11a18358255d08a Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 25 Nov 2024 02:44:23 +0100 Subject: [PATCH] frmts/hdf4/hdf-eos: disable lots of code unused by GDAL --- frmts/hdf4/hdf-eos/EHapi.c | 23 +++++--- frmts/hdf4/hdf-eos/GDapi.c | 91 +++++++++++++++++++++-------- frmts/hdf4/hdf-eos/HdfEosDef.h | 69 +++++++++++++++++++--- frmts/hdf4/hdf-eos/SWapi.c | 104 ++++++++++++++++++++++----------- 4 files changed, 213 insertions(+), 74 deletions(-) diff --git a/frmts/hdf4/hdf-eos/EHapi.c b/frmts/hdf4/hdf-eos/EHapi.c index 3da68c6a9e75..8a6b6af3877d 100644 --- a/frmts/hdf4/hdf-eos/EHapi.c +++ b/frmts/hdf4/hdf-eos/EHapi.c @@ -46,7 +46,9 @@ static int32 *EHXsdTable = NULL; #define MAX_RETRIES 10 /* Function Prototypes */ +#if defined(HDFEOS_GD_WRITE_SUPPORT) || defined(HDFEOS_SW_WRITE_SUPPORT) static intn EHmetalist(const char *, char *); +#endif static intn EHreset_maxopenfiles(intn); static intn EHget_maxopenfiles(intn *, intn *); static intn EHget_numfiles(void); @@ -580,7 +582,7 @@ EHidinfo(int32 fid, int32 * HDFfid, int32 * sdInterfaceID) } - +#ifdef UNUSED_BY_GDAL /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -623,7 +625,7 @@ EHfilename(int32 fid, char *filename) return (status); } - +#endif @@ -1396,6 +1398,7 @@ EHrevflds(const char *dimlist, char *revdimlist) } +#ifdef UNUSED_BY_GDAL /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -1511,10 +1514,11 @@ EHcntGROUP(char *metabuf[]) return (count); } +#endif - +#if defined(HDFEOS_GD_WRITE_SUPPORT) || defined(HDFEOS_SW_WRITE_SUPPORT) /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -1632,11 +1636,11 @@ EHmetalist(const char *instring, char *outstring) return (status); } +#endif - - +#if defined(HDFEOS_GD_WRITE_SUPPORT) || defined(HDFEOS_SW_WRITE_SUPPORT) /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -2391,6 +2395,7 @@ EHinsertmeta(int32 sdInterfaceID, const char *structname, const char *structcode return (status); } +#endif /*----------------------------------------------------------------------------| @@ -2681,7 +2686,7 @@ EHmetagroup(int32 sdInterfaceID, const char *structname, const char *structcode, - +#if defined(HDFEOS_GD_WRITE_SUPPORT) || defined(HDFEOS_SW_WRITE_SUPPORT) /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -2909,12 +2914,12 @@ EHfillfld(int32 sdid, int32 rank, CPL_UNUSED int32 truerank, int32 size, int32 o return (status); } +#endif - - +#ifdef HDFEOS_GD_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -3058,7 +3063,7 @@ EHbisect(float64(*func) (float64[]), float64 funcParms[], int32 nParms, return (status); } - +#endif diff --git a/frmts/hdf4/hdf-eos/GDapi.c b/frmts/hdf4/hdf-eos/GDapi.c index 6ff94e30836c..8b8dde85288c 100644 --- a/frmts/hdf4/hdf-eos/GDapi.c +++ b/frmts/hdf4/hdf-eos/GDapi.c @@ -102,9 +102,11 @@ extern void inv_init(int32, int32, float64 *, int32, const char *, const char * #define GDIDOFFSET 4194304 #define SQUARE(x) ((x) * (x)) /* x**2 */ +#if defined(HDFEOS_GD_WRITE_SUPPORT) static int32 GDXSDcomb[512*5]; -static char GDXSDname[HDFE_NAMBUFSIZE]; static char GDXSDdims[HDFE_DIMBUFSIZE]; +static char GDXSDname[HDFE_NAMBUFSIZE]; +#endif #define NGRID 200 @@ -231,16 +233,21 @@ static intn GDll2ij(int32, int32, float64 [], int32, int32, int32, float64[], float64[], float64[]); static intn GDgetdefaults(int32, int32, float64[], int32, float64[], float64[]); +#ifdef HDFEOS_GD_WRITE_SUPPORT static intn GDtangentpnts(int32, float64[], float64[], float64[], float64[], float64 [], int32 *); +#endif static intn GDwrrdtile(int32, const char *, const char *, int32 [], VOIDP); +#ifdef UNUSED_BY_GDAL static intn GDll2mm_cea(int32,int32, int32, float64[], int32, int32, float64[], float64[], int32, float64[],float64[], float64[], float64[], float64 *, float64 *); - +#endif +#ifdef HDFEOS_GD_WRITE_SUPPORT static intn GDmm2ll_cea(int32, int32, int32, float64[], int32, int32, float64[], float64[], int32, float64[], float64[], float64[], float64[]); +#endif /*----------------------------------------------------------------------------| | BEGIN_PROLOG | @@ -287,7 +294,7 @@ GDopen(const char *filename, intn l_access) } - +#ifdef HDFEOS_GD_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -550,7 +557,7 @@ GDcreate(int32 fid, const char *gridname, int32 xdimsize, int32 ydimsize, } return (gridID); } - +#endif /*----------------------------------------------------------------------------| @@ -909,7 +916,7 @@ GDchkgdid(int32 gridID, const char *routname, } - +#ifdef HDFEOS_GD_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -1558,7 +1565,7 @@ GDdefpixreg(int32 gridID, int32 pixregcode) return (status); } - +#endif @@ -2771,7 +2778,7 @@ GDfieldinfo(int32 gridID, const char *fieldname, int32 * rank, int32 dims[], - +#ifdef HDFEOS_GD_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -3571,7 +3578,7 @@ GDwritefieldmeta(int32 gridID, const char *fieldname, const char *dimlist, } return (status); } - +#endif @@ -4078,7 +4085,7 @@ GDwrrdfield(int32 gridID, const char *fieldname, const char *code, return (status); } - +#ifdef HDFEOS_GD_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -4122,7 +4129,7 @@ GDwritefield(int32 gridID, const char *fieldname, data); return (status); } - +#endif @@ -4241,7 +4248,7 @@ GDwrrdattr(int32 gridID, const char *attrname, int32 numbertype, int32 count, } - +#ifdef HDFEOS_GD_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -4285,7 +4292,7 @@ GDwriteattr(int32 gridID, const char *attrname, int32 numbertype, int32 count, return (status); } - +#endif /*----------------------------------------------------------------------------| @@ -5068,6 +5075,7 @@ GDinqgrid(const char *filename, char *gridlist, int32 * strbufsize) } +#ifdef HDFEOS_GD_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -5153,7 +5161,7 @@ GDsetfillvalue(int32 gridID, const char *fieldname, VOIDP fillval) } return (status); } - +#endif @@ -5272,13 +5280,18 @@ GDdetach(int32 gridID) { intn i; /* Loop index */ +#if defined(HDFEOS_GD_WRITE_SUPPORT) intn j; /* Loop index */ +#endif intn k; /* Loop index */ intn status = 0; /* routine return status variable */ +#if defined(HDFEOS_GD_WRITE_SUPPORT) intn statusFill = 0; /* return status from GDgetfillvalue */ +#endif int32 *namelen; /* Pointer to name string length array */ int32 *dimlen; /* Pointer to dim string length array */ +#if defined(HDFEOS_GD_WRITE_SUPPORT) int32 slen1[3]; /* String length array 1 */ int32 slen2[3]; /* String length array 2 */ int32 nflds; /* Number of fields */ @@ -5287,29 +5300,39 @@ GDdetach(int32 gridID) int32 sdid; /* SDS ID */ int32 vgid; /* Vgroup ID */ int32 dims[3]; /* Dimension array */ +#endif int32 *offset; /* Pointer to merged field offset array */ int32 *indvdims; /* Pointer to merged field size array */ int32 sdInterfaceID; /* SDS interface ID */ int32 gID; /* Grid ID - offset */ +#if defined(HDFEOS_GD_WRITE_SUPPORT) int32 nflds0; /* Number of fields */ +#endif int32 *namelen0; /* Pointer to name string length array */ +#if defined(HDFEOS_GD_WRITE_SUPPORT) int32 rank; /* Rank of merged field */ int32 truerank; /* True rank of merged field */ +#endif int32 idOffset = GDIDOFFSET; /* Grid ID offset */ int32 dum; /* Dummy variable */ +#if defined(HDFEOS_GD_WRITE_SUPPORT) char *nambuf; /* Pointer to name buffer */ +#endif char **nameptr; /* Pointer to name string pointer array */ char **dimptr; /* Pointer to dim string pointer array */ char **nameptr0; /* Pointer to name string pointer array */ +#if defined(HDFEOS_GD_WRITE_SUPPORT) char *ptr1[3]; /* String pointer array */ char *ptr2[3]; /* String pointer array */ char dimbuf1[128]; /* Dimension buffer 1 */ char dimbuf2[128]; /* Dimension buffer 2 */ +#endif char gridname[VGNAMELENMAX + 1]; /* Grid name */ +#if defined(HDFEOS_GD_WRITE_SUPPORT) char *utlbuf; /* Utility buffer */ char fillval[32];/* Fill value buffer */ - +#endif status = GDchkgdid(gridID, "GDdetach", &dum, &sdInterfaceID, &dum); @@ -5325,9 +5348,13 @@ GDdetach(int32 gridID) /* SDS combined fields */ /* ------------------- */ +#if defined(HDFEOS_GD_WRITE_SUPPORT) if (strlen(GDXSDname) == 0) +#endif { +#if defined(HDFEOS_GD_WRITE_SUPPORT) nflds = 0; +#endif /* Allocate "dummy" arrays so free() doesn't bomb later */ /* ---------------------------------------------------- */ @@ -5408,6 +5435,7 @@ GDdetach(int32 gridID) return(-1); } } +#if defined(HDFEOS_GD_WRITE_SUPPORT) else { /* @@ -5507,7 +5535,6 @@ GDdetach(int32 gridID) nflds = EHparsestr(GDXSDdims, ';', dimptr, dimlen); } - for (i = 0; i < nflds; i++) { if (GDXSDcomb[5 * i] != 0 && @@ -5764,7 +5791,7 @@ GDdetach(int32 gridID) strcat(GDXSDname, ","); strcat(GDXSDdims, ";"); } - +#endif /* Free up a bunch of dynamically allocated arrays */ @@ -6676,7 +6703,7 @@ GDll2ij(int32 projcode, int32 zonecode, float64 projparm[], - +#ifdef UNUSED_BY_GDAL /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -6934,9 +6961,10 @@ GDrs2ll(int32 projcode, float64 projparm[], return (status); } +#endif - +#ifdef HDFEOS_GD_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -7124,7 +7152,6 @@ homDyDtheta(float64 parms[]) - /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -8332,11 +8359,11 @@ GDdefboxregion(int32 gridID, float64 cornerlon[], float64 cornerlat[]) free(gridname); return (regionID); } +#endif - - +#ifdef UNUSED_BY_GDAL /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -8966,6 +8993,7 @@ GDdupregion(int32 oldregionID) } return (newregionID); } +#endif /*----------------------------------------------------------------------------| @@ -9046,7 +9074,7 @@ for (j=0; j<8; j++) \ } \ - +#ifdef HDFEOS_GD_WRITE_SUPPORT int32 GDdefvrtregion(int32 gridID, int32 regionID, const char *vertObj, float64 range[]) { @@ -9374,7 +9402,7 @@ GDdeftimeperiod(int32 gridID, int32 periodID, float64 starttime, return (periodID); } - +#endif /*----------------------------------------------------------------------------| @@ -9844,6 +9872,7 @@ GDgetpixvalues(int32 gridID, int32 nPixels, int32 pixRow[], int32 pixCol[], } +#ifdef UNUSED_BY_GDAL /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -10271,6 +10300,8 @@ GDinterpolate(int32 gridID, int32 nValues, float64 lonVal[], float64 latVal[], } } +#endif + /*********************************************** GDwrrdtile -- This function is the underlying function below GDwritetile and @@ -10393,7 +10424,6 @@ GDwrrdtile(int32 gridID, const char *fieldname, const char *code, int32 start[], return (status); } - /*********************************************** GDtileinfo -- This function queries the field to determine if it is tiled. If it is @@ -10496,6 +10526,7 @@ Alexis Zubrow ********************************************************/ +#ifdef HDFEOS_GD_WRITE_SUPPORT intn GDwritetile(int32 gridID, const char *fieldname, int32 tilecoords[], VOIDP tileData) @@ -10507,6 +10538,8 @@ GDwritetile(int32 gridID, const char *fieldname, int32 tilecoords[], return (status); } +#endif + /*********************************************** GDreadtile -- This function reads one tile from a particular field. @@ -10528,6 +10561,8 @@ GDreadtile(int32 gridID, const char *fieldname, int32 tilecoords[], return (status); } + +#ifdef UNUSED_BY_GDAL /*********************************************** GDsettilecache -- This function sets the cache size for a tiled field. @@ -10600,7 +10635,10 @@ GDsettilecache(int32 gridID, const char *fieldname, int32 maxcache, CPL_UNUSED i return (status); } +#endif + +#ifdef HDFEOS_GD_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -10753,7 +10791,9 @@ GDsettilecomp(int32 gridID, const char *fieldname, int32 tilerank, int32* } return (status); } +#endif +#ifdef UNUSED_BY_GDAL /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -10884,8 +10924,10 @@ static intn GDll2mm_cea(int32 projcode,int32 zonecode, int32 spherecode, } return (0); } +#endif +#ifdef HDFEOS_GD_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -10975,6 +11017,7 @@ static intn GDmm2ll_cea(int32 projcode,int32 zonecode, int32 spherecode, } return(status); } +#endif /*----------------------------------------------------------------------------| | BEGIN_PROLOG | diff --git a/frmts/hdf4/hdf-eos/HdfEosDef.h b/frmts/hdf4/hdf-eos/HdfEosDef.h index 88f65dddbd2d..66fe1632d48b 100644 --- a/frmts/hdf4/hdf-eos/HdfEosDef.h +++ b/frmts/hdf4/hdf-eos/HdfEosDef.h @@ -10,9 +10,9 @@ /* Copyright (C) 1996 Hughes and Applied Research Corporation -Permission to use, modify, and distribute this software and its documentation -for any purpose without fee is hereby granted, provided that the above -copyright notice appear in all copies and that both that copyright notice and +Permission to use, modify, and distribute this software and its documentation +for any purpose without fee is hereby granted, provided that the above +copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. */ @@ -81,9 +81,9 @@ this permission notice appear in supporting documentation. /* Compression Modes */ #define HDFE_COMP_NONE 0 -#define HDFE_COMP_RLE 1 +#define HDFE_COMP_RLE 1 #define HDFE_COMP_NBIT 2 -#define HDFE_COMP_SKPHUFF 3 +#define HDFE_COMP_SKPHUFF 3 #define HDFE_COMP_DEFLATE 4 @@ -130,15 +130,20 @@ extern "C" { /* Swath Prototype */ int32 SWopen(const char *, intn); +#ifdef HDFEOS_SW_WRITE_SUPPORT int32 SWcreate(int32, const char *); +#endif int32 SWattach(int32, const char *); +#ifdef HDFEOS_SW_WRITE_SUPPORT intn SWdefdim(int32, char *, int32); intn SWdefcomp(int32, int32, intn []); +#endif int32 SWdiminfo(int32, const char *); intn SWmapinfo(int32, const char *, const char *, int32 *, int32 *); int32 SWidxmapinfo(int32, const char *, const char *, int32 []); intn SWfieldinfo(int32, const char *, int32 *, int32 [], int32 *, char *); intn SWcompinfo(int32, const char *, int32 *, intn []); +#ifdef HDFEOS_SW_WRITE_SUPPORT intn SWdefdimmap(int32, const char *, const char *, int32, int32); intn SWdefidxmap(int32, const char *, const char *, int32 []); intn SWdefgeofield(int32, const char *, const char *, int32, int32); @@ -146,6 +151,7 @@ intn SWdefdatafield(int32, const char *, const char *, int32, int32); intn SWwritegeometa(int32, const char *, const char *, int32); intn SWwritedatameta(int32, const char *, const char *, int32); intn SWwriteattr(int32, const char *, int32, int32, VOIDP); +#endif intn SWreadattr(int32, const char *, VOIDP); intn SWattrinfo(int32, const char *, int32 *, int32 *); int32 SWinqdims(int32, char *, int32 []); @@ -156,31 +162,50 @@ int32 SWinqdatafields(int32, char *, int32 [],int32 []); int32 SWinqattrs(int32, char *, int32 *); int32 SWnentries(int32, int32, int32 *); int32 SWinqswath(const char *, char *, int32 *); +#ifdef HDFEOS_SW_WRITE_SUPPORT intn SWwritefield(int32, const char *, int32 [], int32 [], int32 [], VOIDP); +#endif intn SWreadfield(int32, const char *, int32 [], int32 [], int32 [], VOIDP); +#ifdef HDFEOS_SW_WRITE_SUPPORT int32 SWdefboxregion(int32, float64 [], float64 [], int32); int32 SWdefscanregion(int32, const char *, float64 [], int32); +#endif +#ifdef UNUSED_BY_GDAL int32 SWregionindex(int32, float64 [], float64 [], int32, char *, int32 []); intn SWextractregion(int32, int32, const char *, int32, VOIDP); intn SWregioninfo(int32, int32, const char *, int32 *, int32 *, int32 [], int32 *); int32 SWdupregion(int32); +#endif +#ifdef HDFEOS_SW_WRITE_SUPPORT int32 SWdeftimeperiod(int32, float64, float64, int32); +#endif +#ifdef UNUSED_BY_GDAL intn SWextractperiod(int32, int32, const char *, int32, VOIDP); intn SWperiodinfo(int32, int32, const char *, int32 *, int32 *, int32 [], int32 *); int32 SWdefvrtregion(int32, int32, const char *, float64 []); +#endif +#ifdef HDFEOS_SW_WRITE_SUPPORT intn SWsetfillvalue(int32, const char *, VOIDP); +#endif intn SWgetfillvalue(int32, const char *, VOIDP); intn SWdetach(int32); intn SWclose(int32); +#ifdef HDFEOS_SW_WRITE_SUPPORT int32 SWupdateidxmap(int32, int32, int32 [], int32 [], int32 []); +#endif intn SWgeomapinfo(int32, const char *); +#ifdef HDFEOS_SW_WRITE_SUPPORT intn SWupdatescene(int32, int32); +#endif intn SWsdid(int32, const char *, int32 *); /* Grid Prototypes */ int32 GDopen(const char *, intn); +#ifdef HDFEOS_GD_WRITE_SUPPORT int32 GDcreate(int32, const char *, int32, int32, float64 [], float64 []); +#endif int32 GDattach(int32, const char *); +#ifdef HDFEOS_GD_WRITE_SUPPORT intn GDdefdim(int32, const char *, int32); intn GDdefproj(int32, int32, int32, int32, float64 []); intn GDblkSOMoffset(int32, float32 [], int32, const char *); @@ -189,6 +214,7 @@ intn GDdeftile(int32, int32, int32, int32 []); intn GDsettilecomp(int32, const char *, int32, int32 *, int32, intn *); intn GDdeforigin(int32, int32); intn GDdefpixreg(int32, int32); +#endif int32 GDdiminfo(int32, const char *); intn GDgridinfo(int32, int32 *, int32 *, float64 [], float64 []); intn GDprojinfo(int32, int32 *, int32 *, int32 *, float64 []); @@ -197,15 +223,23 @@ intn GDpixreginfo(int32, int32 *); intn GDcompinfo(int32, const char *, int32 *, intn []); intn GDfieldinfo(int32, const char *, int32 *, int32 [], int32 *, char *); intn GDtileinfo(int32, const char *, int32 *, int32 *, int32 []); +#ifdef UNUSED_BY_GDAL intn GDsettilecache(int32, const char *, int32, int32); +#endif +#ifdef HDFEOS_GD_WRITE_SUPPORT intn GDwritetile(int32, const char *, int32 [], VOIDP); +#endif intn GDreadtile(int32, const char *, int32 [], VOIDP); +#ifdef HDFEOS_GD_WRITE_SUPPORT intn GDdeffield(int32, const char *, const char *, int32, int32); intn GDwritefieldmeta(int32, const char *, const char *, int32); intn GDwritefield(int32, const char *, int32 [], int32 [], int32 [], VOIDP); +#endif intn GDreadfield(int32, const char *, int32 [], int32 [], int32 [], VOIDP); +#ifdef HDFEOS_GD_WRITE_SUPPORT intn GDwriteattr(int32, const char *, int32 , int32, VOIDP); +#endif intn GDreadattr(int32, const char *, VOIDP); intn GDattrinfo(int32, const char *, int32 *, int32 *); int32 GDinqdims(int32, char *, int32 []); @@ -213,26 +247,37 @@ int32 GDinqfields(int32, char *, int32 [], int32 []); int32 GDinqattrs(int32, char *, int32 *); int32 GDnentries(int32, int32, int32 *); int32 GDinqgrid(const char *, char *, int32 *); +#ifdef HDFEOS_GD_WRITE_SUPPORT int32 GDdefboxregion(int32, float64 [], float64 []); int32 GDdefvrtregion(int32, int32, const char *, float64 []); int32 GDdeftimeperiod(int32, int32, float64, float64); +#endif +#ifdef UNUSED_BY_GDAL intn GDextractregion(int32, int32, const char *, VOIDP); intn GDregioninfo(int32, int32, const char *, int32 *, int32 *, int32 [], int32 *, float64 [], float64 []); int32 GDdupregion(int32); +#endif intn GDgetpixels(int32, int32, float64 [], float64 [], int32 [], int32 []); int32 GDgetpixvalues(int32, int32, int32 [], int32 [], const char *, VOIDP); +#ifdef UNUSED_BY_GDAL int32 GDinterpolate(int32, int32, float64 [], float64 [], const char *, float64 []); +#endif +#ifdef HDFEOS_GD_WRITE_SUPPORT intn GDsetfillvalue(int32, const char *, VOIDP); +#endif intn GDgetfillvalue(int32, const char *, VOIDP); intn GDdetach(int32); intn GDclose(int32); +#ifdef UNUSED_BY_GDAL intn GDrs2ll(int32, float64 [], int32, int32, float64 [], float64 [], int32, float64 [], float64 [], float64 [], float64 [], int32, int32); +#endif intn GDsdid(int32, const char *, int32 *); +#ifdef UNUSED_BY_GDAL /* Point Prototypes */ int32 PTopen(const char *, intn); int32 PTcreate(int32, const char *); @@ -268,7 +313,7 @@ intn PTextractregion(int32, int32 regionID, int32, const char *, VOIDP); intn PTextractperiod(int32, int32 periodID, int32, const char *, VOIDP); intn PTdetach(int32); intn PTclose(int32); - +#endif /* EH Utility Prototypes */ @@ -284,21 +329,29 @@ intn EHchkfid(int32, const char *, int32 *, int32 *, uint8 *); intn EHidinfo(int32, int32 *, int32 *); int32 EHgetid(int32, int32, const char *, intn, const char *); intn EHrevflds(const char *, char *); +#if defined(HDFEOS_GD_WRITE_SUPPORT) || defined(HDFEOS_SW_WRITE_SUPPORT) intn EHinsertmeta(int32, const char *, const char *, int32, char *, int32 []); +#endif intn EHgetmetavalue(char *[], const char *, char *); char * EHmetagroup(int32, const char *, const char *, const char *, char *[]); +#if defined(HDFEOS_GD_WRITE_SUPPORT) || defined(HDFEOS_SW_WRITE_SUPPORT) intn EHfillfld(int32, int32, int32, int32, int32, int32 [], VOIDP); +#endif intn EHattr(int32, int32, const char *, int32, int32, const char *, VOIDP); intn EHattrinfo(int32, int32, const char *, int32 *, int32 *); int32 EHattrcat(int32, int32, char *, int32 *); +#ifdef UNUSED_BY_GDAL intn EHfilename(int32, char *); int32 EHcntOBJECT(char *[]); int32 EHcntGROUP(char *[]); -/* 9/3/97 Abe changed the first argument from +#endif +/* 9/3/97 Abe changed the first argument from float64 (float64 []) to float64 (*) (float64 []) for SunOS float64 () (float64 []) to float64 (*) (float64 []) for all other OSs */ -intn EHbisect(float64 (*) (float64 []), float64 [], int32, float64, float64, +#ifdef HDFEOS_GD_WRITE_SUPPORT +intn EHbisect(float64 (*) (float64 []), float64 [], int32, float64, float64, float64, float64 *); +#endif int32 EHinquire(const char *, const char *, char *, int32 *); intn EHclose(int32); diff --git a/frmts/hdf4/hdf-eos/SWapi.c b/frmts/hdf4/hdf-eos/SWapi.c index 4e51d32666bc..27c11e3340a9 100644 --- a/frmts/hdf4/hdf-eos/SWapi.c +++ b/frmts/hdf4/hdf-eos/SWapi.c @@ -88,15 +88,21 @@ June 05, 2003 Abe Taaheri / Bruce Beaumont static int32 SWX1dcomb[512*3]; +#ifdef HDFEOS_SW_WRITE_SUPPORT static int32 SWXSDcomb[512*5]; +#endif static char SWXSDname[HDFE_NAMBUFSIZE]; +#ifdef HDFEOS_SW_WRITE_SUPPORT static char SWXSDdims[HDFE_DIMBUFSIZE]; +#endif +#ifdef UNUSED_BY_GDAL /* This flag was added to allow the Time field to have different Dimensions ** than Longitude and Latitude and still be used for subsetting ** 23 June,1997 DaW */ static intn timeflag = 0; +#endif /* Added for routine that converts scanline to Lat/long @@ -158,7 +164,9 @@ static struct swathRegion *SWXRegion[NSWATHREGN]; static intn SWchkswid(int32, const char *, int32 *, int32 *, int32 *); static int32 SWfinfo(int32, const char *, const char *, int32 *, int32 [], int32 *, char *); +#ifdef HDFEOS_SW_WRITE_SUPPORT static intn SWdefinefield(int32, const char *, const char *, const char *, int32, int32); +#endif static intn SWwrrdattr(int32, const char *, int32, int32, const char *, VOIDP); static intn SW1dfldsrch(int32, int32, const char *, const char *, int32 *, int32 *, int32 *); @@ -167,9 +175,10 @@ static intn SWSDfldsrch(int32, int32, const char *, int32 *, int32 *, static intn SWwrrdfield(int32, const char *, const char *, int32 [], int32 [], int32 [], VOIDP); static int32 SWinqfields(int32, const char *, char *, int32 [], int32 []); +#ifdef UNUSED_BY_GDAL static intn SWscan2longlat(int32, const char *, VOIDP, int32 [], int32 [], int32 *, int32, int32); - +#endif /*----------------------------------------------------------------------------| | BEGIN_PROLOG | @@ -213,6 +222,7 @@ SWopen(const char *filename, intn i_access) return (fid); } +#ifdef HDFEOS_SW_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -455,7 +465,7 @@ SWcreate(int32 fid, const char *swathname) } return (swathID); } - +#endif /*----------------------------------------------------------------------------| | BEGIN_PROLOG | @@ -874,7 +884,7 @@ SWchkswid(int32 swathID, const char *routname, - +#ifdef HDFEOS_SW_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -951,7 +961,7 @@ SWdefdim(int32 swathID, char *dimname, int32 dim) } return (status); } - +#endif /*----------------------------------------------------------------------------| @@ -1840,7 +1850,7 @@ SWfieldinfo(int32 swathID, const char *fieldname, int32 * rank, int32 dims[], - +#ifdef HDFEOS_SW_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -2842,7 +2852,6 @@ SWdefinefield(int32 swathID, const char *fieldtype, const char *fieldname, const - /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -3077,6 +3086,7 @@ SWwritedatameta(int32 swathID, const char *fieldname, const char *dimlist, } return (status); } +#endif @@ -3145,7 +3155,7 @@ SWwrrdattr(int32 swathID, const char *attrname, int32 numbertype, int32 count, } - +#ifdef HDFEOS_SW_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -3189,7 +3199,7 @@ SWwriteattr(int32 swathID, const char *attrname, int32 numbertype, int32 count, return (status); } - +#endif /*----------------------------------------------------------------------------| @@ -5262,7 +5272,7 @@ SWwrrdfield(int32 swathID, const char *fieldname, const char *code, } - +#ifdef HDFEOS_SW_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -5306,7 +5316,7 @@ SWwritefield(int32 swathID, const char *fieldname, data); return (status); } - +#endif @@ -5358,7 +5368,7 @@ SWreadfield(int32 swathID, const char *fieldname, - +#ifdef HDFEOS_SW_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -5988,10 +5998,11 @@ SWdefboxregion(int32 swathID, float64 cornerlon[], float64 cornerlat[], } } +#endif - +#ifdef UNUSED_BY_GDAL /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -6631,9 +6642,9 @@ SWregionindex(int32 swathID, float64 cornerlon[], float64 cornerlat[], } } +#endif - - +#ifdef HDFEOS_SW_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -6928,7 +6939,9 @@ SWdeftimeperiod(int32 swathID, float64 starttime, float64 stoptime, return (periodID); } +#endif +#ifdef UNUSED_BY_GDAL /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -7756,6 +7769,7 @@ SWextractregion(int32 swathID, int32 regionID, const char *fieldname, } + /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -8109,6 +8123,7 @@ int32 edge[], int32 *idxmap, int32 startscanline, int32 stopscanline) } + /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -8158,13 +8173,13 @@ SWextractperiod(int32 swathID, int32 periodID, const char *fieldname, if (status != 0) timeflag = 0; /*clear timeflag if SWextractregion failed*/ return (status); } +#endif - - +#ifdef UNUSED_BY_GDAL /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -8231,8 +8246,10 @@ SWdupregion(int32 oldregionID) return (newregionID); } +#endif +#ifdef UNUSED_BY_GDAL /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -8898,9 +8915,9 @@ SWregioninfo(int32 swathID, int32 regionID, const char *fieldname, return (status); } +#endif - - +#ifdef UNUSED_BY_GDAL /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -9518,9 +9535,10 @@ SWdefvrtregion(int32 swathID, int32 regionID, const char *vertObj, float64 range return (regionID); } +#endif - +#ifdef HDFEOS_SW_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -9894,7 +9912,7 @@ SWsetfillvalue(int32 swathID, const char *fieldname, VOIDP fillval) } return (status); } - +#endif @@ -10002,16 +10020,21 @@ SWdetach(int32 swathID) { intn i; /* Loop index */ +#ifdef HDFEOS_SW_WRITE_SUPPORT intn j; /* Loop index */ +#endif intn k; /* Loop index */ intn status = 0; /* routine return status variable */ +#ifdef HDFEOS_SW_WRITE_SUPPORT intn statusFill = 0; /* return status from SWgetfillvalue */ +#endif uint8 *buf; /* Buffer for blank (initial) 1D records */ int32 vdataID; /* Vdata ID */ - int32 *namelen; /* Pointer to name string length array */ - int32 *dimlen; /* Pointer to dim string length array */ + int32 *namelen = NULL; /* Pointer to name string length array */ + int32 *dimlen = NULL; /* Pointer to dim string length array */ +#ifdef HDFEOS_SW_WRITE_SUPPORT int32 slen1[3]; /* String length array 1 */ int32 slen2[3]; /* String length array 2 */ int32 nflds; /* Number of fields */ @@ -10019,29 +10042,38 @@ SWdetach(int32 swathID) int32 cmbfldcnt; /* Number of fields combined */ int32 sdid; /* SDS ID */ int32 vgid; /* Vgroup ID */ +#endif int32 dims[3]; /* Dimension array */ - int32 *offset; /* Pointer to merged field offset array */ - int32 *indvdims; /* Pointer to merged field size array */ + int32 *offset = NULL; /* Pointer to merged field offset array */ + int32 *indvdims = NULL; /* Pointer to merged field size array */ int32 sdInterfaceID; /* SDS interface ID */ int32 sID; /* Swath ID - offset */ +#ifdef HDFEOS_SW_WRITE_SUPPORT int32 nflds0; /* Number of fields */ - int32 *namelen0; /* Pointer to name string length array */ +#endif + int32 *namelen0 = NULL; /* Pointer to name string length array */ +#ifdef HDFEOS_SW_WRITE_SUPPORT int32 rank; /* Rank of merged field */ int32 truerank; /* True rank of merged field */ +#endif int32 idOffset = SWIDOFFSET; /* Swath ID offset */ int32 dum; /* Dummy variable */ - char *nambuf; /* Pointer to name buffer */ - char **nameptr; /* Pointer to name string pointer array */ - char **dimptr; /* Pointer to dim string pointer array */ - char **nameptr0; /* Pointer to name string pointer array */ + char *nambuf = NULL; /* Pointer to name buffer */ + char **nameptr = NULL; /* Pointer to name string pointer array */ + char **dimptr = NULL; /* Pointer to dim string pointer array */ + char **nameptr0 = NULL; /* Pointer to name string pointer array */ +#ifdef HDFEOS_SW_WRITE_SUPPORT char *ptr1[3]; /* String pointer array */ char *ptr2[3]; /* String pointer array */ char dimbuf1[128]; /* Dimension buffer 1 */ char dimbuf2[128]; /* Dimension buffer 2 */ +#endif char swathname[VGNAMELENMAX + 1]; /* Swath name */ +#ifdef HDFEOS_SW_WRITE_SUPPORT char *utlbuf; /* Utility buffer */ char fillval[32];/* Fill value buffer */ +#endif /* Check for proper swath ID and get SD interface ID */ /* ------------------------------------------------- */ @@ -10117,7 +10149,9 @@ SWdetach(int32 swathID) /* ------------------- */ if (strlen(SWXSDname) == 0) { +#ifdef HDFEOS_SW_WRITE_SUPPORT nflds = 0; +#endif /* Allocate "dummy" arrays so free() doesn't bomb later */ /* ---------------------------------------------------- */ @@ -10198,6 +10232,7 @@ SWdetach(int32 swathID) return(-1); } } +#if defined(HDFEOS_SW_WRITE_SUPPORT) else { /* @@ -10299,7 +10334,6 @@ SWdetach(int32 swathID) nflds = EHparsestr(SWXSDdims, ';', dimptr, dimlen); } - /* Loop through all the fields */ /* --------------------------- */ for (i = 0; i < nflds; i++) @@ -10598,6 +10632,7 @@ SWdetach(int32 swathID) free(utlbuf); } } +#endif @@ -10616,7 +10651,7 @@ SWdetach(int32 swathID) i++; } - +#ifdef HDFEOS_SW_WRITE_SUPPORT /* "Contract" SDcomb array */ /* ----------------------- */ for (i = 0; i < nflds; i++) @@ -10658,7 +10693,7 @@ SWdetach(int32 swathID) strcat(SWXSDname, ","); strcat(SWXSDdims, ";"); } - +#endif /* Free up a bunch of dynamically allocated arrays */ @@ -10768,6 +10803,7 @@ SWclose(int32 fid) return (status); } +#ifdef HDFEOS_SW_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -10928,7 +10964,9 @@ SWupdatescene(int32 swathID, int32 regionID) return(status); } +#endif +#ifdef HDFEOS_SW_WRITE_SUPPORT /*----------------------------------------------------------------------------| | BEGIN_PROLOG | | | @@ -11416,7 +11454,7 @@ SWupdateidxmap(int32 swathID, int32 regionID, int32 l_indexin[], int32 l_indexou } } - +#endif /*----------------------------------------------------------------------------|