summaryrefslogtreecommitdiffstats
path: root/hl/tools/gif2h5
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2001-06-18 20:22:10 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2001-06-18 20:22:10 (GMT)
commitd41b9fffdfca2e97c36bc0ad0899fbb7b055f926 (patch)
tree51ed39b08a41a4f6947af07630eb40dfdb013d87 /hl/tools/gif2h5
parentfcaf572430a8eda3f6519bd21311ef7a8e3c3c1f (diff)
downloadhdf5-d41b9fffdfca2e97c36bc0ad0899fbb7b055f926.zip
hdf5-d41b9fffdfca2e97c36bc0ad0899fbb7b055f926.tar.gz
hdf5-d41b9fffdfca2e97c36bc0ad0899fbb7b055f926.tar.bz2
[svn-r4012] Purpose:
Clean up compiler warnings. Description: Just code neatening mostly, some casts, etc. Platforms tested: FreeBSD 4.3 (hawkwind)
Diffstat (limited to 'hl/tools/gif2h5')
-rw-r--r--hl/tools/gif2h5/decompress.c12
-rw-r--r--hl/tools/gif2h5/gif.h1
-rw-r--r--hl/tools/gif2h5/gif2hdf.c9
-rw-r--r--hl/tools/gif2h5/gif2mem.c1
-rw-r--r--hl/tools/gif2h5/gifread.c39
-rw-r--r--hl/tools/gif2h5/hdf2gif.c21
-rw-r--r--hl/tools/gif2h5/hdfgifwr.c60
-rw-r--r--hl/tools/gif2h5/readhdf.c19
-rw-r--r--hl/tools/gif2h5/writehdf.c18
9 files changed, 68 insertions, 112 deletions
diff --git a/hl/tools/gif2h5/decompress.c b/hl/tools/gif2h5/decompress.c
index 18dbb3e..abccb7f 100644
--- a/hl/tools/gif2h5/decompress.c
+++ b/hl/tools/gif2h5/decompress.c
@@ -19,13 +19,8 @@ static int BitOffset = 0, /* Bit Offset of next code */
XC = 0, YC = 0, /* Output X and Y coords of current pixel */
Pass = 0, /* Used by output routine if WORDerlaced pic */
OutCount = 0, /* Decompressor output 'stack count' */
-RWidth, RHeight, /* screen dimensions */
IWidth, IHeight, /* image dimensions */
-LeftOfs, TopOfs, /* image offset */
-BitsPerPixel, /* Bits per pixel, read from GIF header */
BytesPerScanline, /* Bytes per scanline in output raster */
-ColorMapSize, /* number of colors */
-Background, /* background color */
CodeSize, /* Code size, read from GIF header */
InitCodeSize, /* Starting code size, used during Clear */
Code, /* Value returned by ReadCode */
@@ -73,7 +68,7 @@ int numused;
* three BYTEs, compute the bit Offset WORDo our 24-bit chunk, shift to
* bring the desired code to the bottom, then mask it off and return it.
*/
-ReadCode()
+static int ReadCode(void)
{
int RawCode, ByteOffset;
@@ -87,8 +82,7 @@ ReadCode()
}
-AddToPixel(Index)
-BYTE Index;
+static void AddToPixel(BYTE Index)
{
if (YC<IHeight)
*(Image + YC * BytesPerScanline + XC) = Index;
@@ -202,7 +196,7 @@ GIFHEAD *GifHead;
/* Allocate the Image */
- if (!(Image = (BYTE *)malloc(IWidth*IHeight))) {
+ if (!(Image = (BYTE *)malloc((size_t)IWidth*(size_t)IHeight))) {
printf("Out of memory");
exit(-1);
}
diff --git a/hl/tools/gif2h5/gif.h b/hl/tools/gif2h5/gif.h
index f697881..3f2a8da 100644
--- a/hl/tools/gif2h5/gif.h
+++ b/hl/tools/gif2h5/gif.h
@@ -169,7 +169,6 @@ int WriteHDF(GIFTOMEM , CHAR * , CHAR *);
*/
int ReadHDF(BYTE** data , BYTE palette[256][3] , hsize_t *image_size , CHAR *h5_file , CHAR *dset_name , CHAR *pal_name);
-BYTE *ReadDataSubBlocks(BYTE ** , WORD *);
BYTE *Decompress (GIFIMAGEDESC * , GIFHEAD *);
BYTE GetByte(BYTE *);
WORD GetWord(BYTE *);
diff --git a/hl/tools/gif2h5/gif2hdf.c b/hl/tools/gif2h5/gif2hdf.c
index 0211143..6b4ae2b 100644
--- a/hl/tools/gif2h5/gif2hdf.c
+++ b/hl/tools/gif2h5/gif2hdf.c
@@ -3,10 +3,9 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+
int
-main(argv , argc)
-int argv;
-char *argc[];
+main(int argv , char *argc[])
{
GIFTOMEM GifMemoryStruct;
@@ -60,11 +59,11 @@ char *argc[];
filesize = ftell(fpGif);
fseek(fpGif, 0L , 0);
if (filesize == 0) printf("File Size Zero");
- if (!(MemGif = StartPos = (BYTE *)malloc(filesize))) {
+ if (!(MemGif = StartPos = (BYTE *)malloc((size_t)filesize))) {
printf("Out of memory");
exit (-1);
}
- if (fread(MemGif,filesize,1,fpGif) != 1) {
+ if (fread(MemGif,(size_t)filesize,1,fpGif) != 1) {
printf("Corrupted Input File");
exit(-1);
}
diff --git a/hl/tools/gif2h5/gif2mem.c b/hl/tools/gif2h5/gif2mem.c
index 92ca8e5..830eba7 100644
--- a/hl/tools/gif2h5/gif2mem.c
+++ b/hl/tools/gif2h5/gif2mem.c
@@ -25,7 +25,6 @@
/* #include <hdf.h> */
#define VERSION "1.00"
-extern int EndianOrder;
GIFTOMEM
Gif2Mem(MemGif)
diff --git a/hl/tools/gif2h5/gifread.c b/hl/tools/gif2h5/gifread.c
index 1196241..cb033d9 100644
--- a/hl/tools/gif2h5/gifread.c
+++ b/hl/tools/gif2h5/gifread.c
@@ -3,14 +3,14 @@
#include "gif.h"
int EndianOrder;
-int i;
+static BYTE * ReadDataSubBlocks(BYTE **MemGif2, WORD *DSize);
WORD
GetWord (MemGif)
BYTE *MemGif;
{
- register WORD w;
+ WORD w;
if (EndianOrder == 1) /* LittleEndian */
{
w = (WORD) (*MemGif++ & 0xFF);
@@ -46,14 +46,14 @@ ReadGifHeader(GifHead, MemGif2)
GIFHEAD *GifHead; /* Pointer to GIF header structure */
BYTE **MemGif2; /* GIF image file input FILE stream */
{
- register WORD i; /* Loop counter */
+ WORD i; /* Loop counter */
WORD tableSize; /* Number of entires in the Global Color Table */
GifHead->TableSize = 0;
for (i = 0 ; i < 6 ; i++) {
GifHead->HeaderDump[i] = *(*MemGif2)++;
}
- if (strncmp(GifHead->HeaderDump , "GIF" , 3)) {
+ if (strncmp((const char *)GifHead->HeaderDump , "GIF" , 3)) {
printf("The file does not appear to be a valid GIF file.\n");
exit(-1);
}
@@ -114,9 +114,9 @@ ReadGifImageDesc(GifImageDesc, MemGif2)
GIFIMAGEDESC *GifImageDesc; /* Pointer to GIF image descriptor structure */
BYTE **MemGif2; /* GIF image file input FILE stream */
{
- register WORD i; /* Loop counter */
+ WORD i; /* Loop counter */
WORD tableSize; /* Number of entries in the Local Color Table */
- BYTE Interlace; /* PackedField & 0x20 gives information on interlacing */
+ /* BYTE Interlace; */ /* PackedField & 0x20 gives information on interlacing */
BYTE *TempPtr;
int ch , ch1;
@@ -210,11 +210,11 @@ ReadGifGraphicControl(GifGraphicControl, MemGif2)
GIFGRAPHICCONTROL *GifGraphicControl; /* Pointer to GC Extension structure */
BYTE **MemGif2; /* GIF image file input FILE stream */
{
+ int i;
-
- for (i = 0 ; i < 5 ; i++) {
- GifGraphicControl->GCEDump[i] = *(*MemGif2)++;
- }
+ for (i = 0 ; i < 5 ; i++) {
+ GifGraphicControl->GCEDump[i] = *(*MemGif2)++;
+ }
return(0); /* No FILE stream error occured */
}
@@ -234,6 +234,8 @@ ReadGifPlainText(GifPlainText, MemGif2)
GIFPLAINTEXT *GifPlainText; /* Pointer to Plain Text Extension structure */
BYTE **MemGif2; /* GIF image file input FILE stream */
{
+ int i;
+
for (i = 0 ; i < 13 ; i++) {
GifPlainText->PTEDump[i] = *(*MemGif2)++;
}
@@ -270,6 +272,8 @@ ReadGifApplication(GifApplication, MemGif2)
GIFAPPLICATION *GifApplication; /* Pointer to Application Extension structure */
BYTE **MemGif2; /* GIF image file input FILE stream */
{
+ int i;
+
for (i = 0 ; i < 12 ; i++) {
GifApplication->AEDump[i] = *(*MemGif2)++;
}
@@ -327,9 +331,8 @@ BYTE **MemGif2; /* GIF image file input FILE stream */
** otherwise a valid pointer if no error occured.
*/
static BYTE *
-ReadDataSubBlocks(MemGif2 , DSize)
-BYTE **MemGif2; /* GIF image file input FILE stream */
-WORD *DSize;
+ReadDataSubBlocks(BYTE **MemGif2, /* GIF image file input FILE stream */
+ WORD *DSize)
{
BYTE *ptr1; /* Pointer used to "walk the heap" */
BYTE *ptr2; /* Pointer used to mark the top of the heap */
@@ -342,7 +345,7 @@ WORD *DSize;
dataSize = *(*MemGif2)++; /* Get the size of the first sub-block */
/* Allocate initial data buffer */
- if (!(ptr1 = ptr2 = (BYTE *) malloc(dataSize + 1))) {
+ if (!(ptr1 = ptr2 = (BYTE *) malloc((size_t)dataSize + 1))) {
printf("Out of memory. Allocation of memory for data sub-blocks for\neither Comment, Plain Text or Application Extensions failed");
return((BYTE *) NULL);
}
@@ -352,7 +355,9 @@ WORD *DSize;
bufSize += (dataSize); /* Running total of the buffer size */
*DSize = bufSize;
- /* *ptr1++ = dataSize; /* Write the data count */
+#ifdef COMMENTED_OUT
+ *ptr1++ = dataSize; /* Write the data count */
+#endif /* COMMENTED_OUT */
while (dataSize--) /* Read/write the Plain Text data */
*ptr1++ = *(*MemGif2)++;
@@ -370,7 +375,9 @@ WORD *DSize;
}
- /**ptr1++ = (BYTE) NULL; /* Add NULL to simulate Terminator value */
+#ifdef COMMENTED_OUT
+ *ptr1++ = (BYTE) NULL; /* Add NULL to simulate Terminator value */
+#endif /* COMMENTED_OUT */
*ptr1++ = '\0';
return(ptr2); /* Return a pointer to the sub-block data */
diff --git a/hl/tools/gif2h5/hdf2gif.c b/hl/tools/gif2h5/hdf2gif.c
index 9c4133e..39c75d1 100644
--- a/hl/tools/gif2h5/hdf2gif.c
+++ b/hl/tools/gif2h5/hdf2gif.c
@@ -19,16 +19,18 @@ extern int hdfWriteGIF(FILE *fp, BYTE *pic, int ptype, int w, int h, BYTE *rmap,
int EndianOrder;
-void PutByte(BYTE b , FILE *fpGif)
+#ifdef NOT_USED
+static void PutByte(BYTE b , FILE *fpGif)
{
if (fputc(b , fpGif) == EOF) {
printf("File Writing Error, cannot continue");
exit(-1);
}
}
+#endif /* NOT_USED */
-void putword(int w, FILE *fp)
+static void putword(int w, FILE *fp)
{
/* writes a 16-bit integer in GIF order (LSB first) */
@@ -37,7 +39,8 @@ void putword(int w, FILE *fp)
fputc((w>>8)&0xff,fp);
}
-void usage() {
+static void usage(void )
+{
printf("Usage: h52gif <h5_file> <gif_file> -i <h5_image> [-p <h5_palette>]\n");
printf("h52gif expects *at least* one h5_image. You may repeat -i <h5_image> [-p <h5_palette>] at most 50 times (maximum of 50 images).\n");
}
@@ -53,8 +56,6 @@ int main(int argc , char **argv) {
CHAR *HDFName = NULL;
CHAR *GIFName = NULL;
- CHAR *image_path = NULL;
- CHAR *pal_path = NULL;
/* reference variables */
int has_local_palette; /* treated as a flag */
@@ -76,7 +77,7 @@ int main(int argc , char **argv) {
int CountDown;
int curx , cury;
int time_out = 0; /* time between two images in the animation */
- int n_images , index;
+ int n_images , idx;
BYTE pc2nc[256] , r1[256] , g1[256] , b1[256];
@@ -172,7 +173,7 @@ int main(int argc , char **argv) {
n_images = number_of_images;
Background = 0;
- for (index = 0 ; index < n_images ; index++) {
+ for (idx = 0 ; idx < n_images ; idx++) {
/* try to read the image and the palette */
/* Lots of funky stuff to support multiple images has been taken off.
@@ -183,7 +184,7 @@ int main(int argc , char **argv) {
** to write the global palette out and then independantly write the smaller local
** palettes
*/
- if (ReadHDF(&Image , GlobalPalette , dim_sizes , HDFName , image_name_arr[index] , pal_name_arr[index]) < 0) {
+ if (ReadHDF(&Image , GlobalPalette , dim_sizes , HDFName , image_name_arr[idx] , pal_name_arr[idx]) < 0) {
fprintf(stderr , "Unable to read HDF file\n");
return -1;
}
@@ -257,7 +258,7 @@ int main(int argc , char **argv) {
/* If it is the first image we do all the header stuff that isn't required for the
** rest of the images.
*/
- if (index == 0) {
+ if (idx == 0) {
/* Write out the GIF header and logical screen descriptor */
if (n_images > 1) {
fwrite("GIF89a", 1, 6, fpGif); /* the GIF magic number */
@@ -331,7 +332,7 @@ int main(int argc , char **argv) {
fputc (InitCodeSize , fpGif);
- i = hdfWriteGIF(fpGif , Image , 0 , dim_sizes[0] , dim_sizes[1] , r1, g1 , b1 , pc2nc , 256 , 8 , BitsPerPixel);
+ i = hdfWriteGIF(fpGif , Image , 0 , (int)dim_sizes[0] , (int)dim_sizes[1] , r1, g1 , b1 , pc2nc , 256 , 8 , BitsPerPixel);
fputc(0x00 , fpGif);
free (Image);
}
diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c
index 28d556e..62b3eae 100644
--- a/hl/tools/gif2h5/hdfgifwr.c
+++ b/hl/tools/gif2h5/hdfgifwr.c
@@ -67,7 +67,6 @@ static long CountDown;
static int Interlace;
#ifdef __STDC__
-static void putword(int, FILE *);
static void compress(int, FILE *, byte *, int);
static void output(int);
static void cl_block(void);
@@ -76,27 +75,16 @@ static void char_init(void);
static void char_out(int);
static void flush_char(void);
#else
-static void putword(), compress(), output(), cl_block(), cl_hash();
+static void compress(), output(), cl_block(), cl_hash();
static void char_init(), char_out(), flush_char();
#endif
static byte pc2nc[256],r1[256],g1[256],b1[256];
-void xvbzero(s, len)
- char *s;
- int len;
-{
- for ( ; len>0; len--) *s++ = 0;
-}
-
/*************************************************************/
-int hdfWriteGIF(fp, pic, ptype, w, h, rmap, gmap, bmap, pc2ncmap, numcols, colorstyle, BitsPerPixel)
- FILE *fp;
- byte *pic;
- int ptype, w,h;
- byte *rmap, *gmap, *bmap , *pc2ncmap;
- int numcols, colorstyle;
- int BitsPerPixel;
+int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap,
+ byte *gmap, byte *bmap, byte *pc2ncmap, int numcols, int colorstyle,
+ int BitsPerPixel)
{
int RWidth, RHeight;
int LeftOfs, TopOfs;
@@ -143,21 +131,6 @@ int hdfWriteGIF(fp, pic, ptype, w, h, rmap, gmap, bmap, pc2ncmap, numcols, colo
-/******************************/
-static void putword(w, fp)
-int w;
-FILE *fp;
-{
- /* writes a 16-bit integer in GIF order (LSB first) */
-
- fputc(w &0xff, fp);
-
- fputc((w>>8)&0xff,fp);
-}
-
-
-
-
/***********************************************************************/
static unsigned long cur_accum = 0;
static int cur_bits = 0;
@@ -252,8 +225,8 @@ int len;
/* initialize 'compress' globals */
maxbits = XV_BITS;
maxmaxcode = 1<<XV_BITS;
- xvbzero((char *) htab, sizeof(htab));
- xvbzero((char *) codetab, sizeof(codetab));
+ memset(htab, 0, sizeof(htab));
+ memset(codetab, 0, sizeof(codetab));
hsize = HSIZE;
free_ent = 0;
clear_flg = 0;
@@ -375,7 +348,7 @@ int code;
cur_bits += n_bits;
while( cur_bits >= 8 ) {
- char_out( (unsigned int) (cur_accum & 0xff) );
+ char_out( (int)((unsigned int) cur_accum & 0xff) );
cur_accum >>= 8;
cur_bits -= 8;
}
@@ -403,7 +376,7 @@ int code;
if( code == EOFCode ) {
/* At EOF, write the rest of the buffer */
while( cur_bits > 0 ) {
- char_out( (unsigned int)(cur_accum & 0xff) );
+ char_out( (int)((unsigned int)cur_accum & 0xff) );
cur_accum >>= 8;
cur_bits -= 8;
}
@@ -434,14 +407,14 @@ static void cl_block () /* table clear for block compress */
/********************************/
-static void cl_hash(hsize) /* reset code table */
-register count_int hsize;
+static void cl_hash(hashsize) /* reset code table */
+count_int hashsize;
{
- register count_int *htab_p = htab+hsize;
- register long i;
- register long m1 = -1;
+ count_int *htab_p = htab+hashsize;
+ long i;
+ long m1 = -1;
- i = hsize - 16;
+ i = hashsize - 16;
do { /* might use Sys V memset(3) here */
*(htab_p-16) = m1;
*(htab_p-15) = m1;
@@ -495,8 +468,7 @@ static char accum[ 256 ];
* Add a character to the end of the current packet, and if it is 254
* characters, flush the packet to disk.
*/
-static void char_out(c)
-int c;
+static void char_out(int c)
{
accum[ a_count++ ] = c;
if( a_count >= 254 )
@@ -510,7 +482,7 @@ static void flush_char()
{
if( a_count > 0 ) {
fputc( a_count, g_outfile );
- fwrite( accum, 1, a_count, g_outfile );
+ fwrite( accum, 1, (size_t)a_count, g_outfile );
a_count = 0;
}
}
diff --git a/hl/tools/gif2h5/readhdf.c b/hl/tools/gif2h5/readhdf.c
index a7101c9..52a1837 100644
--- a/hl/tools/gif2h5/readhdf.c
+++ b/hl/tools/gif2h5/readhdf.c
@@ -35,14 +35,10 @@ int ReadHDF(BYTE** data ,
herr_t status; /* status variable */
hid_t dspace; /* dataspace identifier for the the dataset */
hid_t dset; /* dataset identifier */
-
hid_t pal_set; /* dataset for palette */
hid_t pal_space;/* dataspace for palette */
- hsize_t pal_size; /* size of the palette */
-
hsize_t datasize; /* size of the image */
hsize_t maxdims; /* dummy */
-
int pal_exist = 0; /* do we have a palette? */
/* check stuff */
@@ -85,7 +81,7 @@ int ReadHDF(BYTE** data ,
datasize = image_size[0] * image_size[1];
/* allocate memory to store the image */
- if ((*data = (BYTE*) malloc(datasize)) == NULL) {
+ if ((*data = (BYTE*) malloc((size_t)datasize)) == NULL) {
fprintf(stderr , "Out of memory, exiting");
return -1;
}
@@ -98,11 +94,8 @@ int ReadHDF(BYTE** data ,
}
if (pal_exist) {
- hsize_t pal_size[2];
- hsize_t max_pal_dims[2];
+ hsize_t loc_pal_size[2];
hsize_t pal_datasize;
- CHAR *pal_path;
-
BYTE *temp_buf;
hsize_t temp_size;
@@ -121,19 +114,19 @@ int ReadHDF(BYTE** data ,
}
/* get the dimension size of the palette. */
- if (H5Sget_simple_extent_dims(pal_space , pal_size , &max_pal_dims) !=2 ) {
+ if (H5Sget_simple_extent_dims(pal_space , loc_pal_size , NULL) !=2 ) {
fprintf(stderr , "Unable to get dimension info\n");
pal_exist = 0;
return -1;
}
/* size needed to store the image */
- pal_datasize = pal_size[0] * pal_size[1];
+ pal_datasize = loc_pal_size[0] * loc_pal_size[1];
/* copy stuff into a temp buffer and then copy 256*3 elements to palette */
temp_size = H5Dget_storage_size(pal_set);
- temp_buf = (BYTE*) malloc (temp_size * sizeof(BYTE));
+ temp_buf = (BYTE*) malloc ((size_t)temp_size * sizeof(BYTE));
/* make sure that the palette is actually 256 X 3 so that we don't create overflows */
if (pal_datasize > 256 * 3)
@@ -152,7 +145,7 @@ int ReadHDF(BYTE** data ,
}
/* copy stuff into the actual palette */
- memcpy(palette , temp_buf , pal_datasize);
+ memcpy(palette , temp_buf , (size_t)pal_datasize);
/* get rid of the temp memory */
cleanup(temp_buf);
diff --git a/hl/tools/gif2h5/writehdf.c b/hl/tools/gif2h5/writehdf.c
index 7afccdf..5426c27 100644
--- a/hl/tools/gif2h5/writehdf.c
+++ b/hl/tools/gif2h5/writehdf.c
@@ -7,7 +7,8 @@
** Function: write_text_attribute
** Use: Just a small wrapper to write text attributes easily
********************************************************************/
-int write_text_attribute(hid_t dataset_id , char *attr_name , char *attr_value) {
+static int write_text_attribute(hid_t dataset_id , const char *attr_name , const char *attr_value)
+{
/* variables for the attributes */
hsize_t attr_dims_size; /* dimensions for the attribute */
@@ -26,7 +27,7 @@ int write_text_attribute(hid_t dataset_id , char *attr_name , char *attr_value)
/* set the type to string */
attr_type_id = H5Tcopy(H5T_C_S1);
- H5Tset_size(attr_type_id , attr_dims_size);
+ H5Tset_size(attr_type_id , (size_t)attr_dims_size);
/* create the dataspace for the attribute */
attr_dataspace_id = H5Screate_simple(1 , &attr_dims_size , NULL);
@@ -59,18 +60,14 @@ char *HDFName;
char *GIFFileName;
{
GIFHEAD gifHead; /* GIF Header structure */
- GIFIMAGEDESC* gifImageDesc; /* Logical Image Descriptor struct */
+ GIFIMAGEDESC* gifImageDesc; /* Logical Image Descriptor struct */
long ImageCount , /* number of images */
CommentCount, /* number of comments */
ApplicationCount , /* number of application extensions */
PlainTextCount; /* number of plain text extensions */
- char ImageName[256], /* Image name for the GR Image */
- CommentName[256],
- ApplicationName[256],
- PlainTextName[256];
-
+ char ImageName[256]; /* Image name for the GR Image */
char GroupName[VSNAMELENMAX]; /* so that we can name the subgroups appropriately */
/* H5 variables */
@@ -82,11 +79,6 @@ char *GIFFileName;
/* temp counter */
int i;
-
-
-
-
-
/* get the GIFMem stuff */
gifHead = *(GifMemoryStruct.GifHeader);