summaryrefslogtreecommitdiffstats
path: root/tools/gifconv/gif2hdf.c
diff options
context:
space:
mode:
authorBill Wendling <wendling@ncsa.uiuc.edu>2001-07-24 17:51:22 (GMT)
committerBill Wendling <wendling@ncsa.uiuc.edu>2001-07-24 17:51:22 (GMT)
commite685336ab13081f8e4a92b7a4a9b6bf022ae5b23 (patch)
treec6858498dd0d2357f6736df7f2095b5453394bf1 /tools/gifconv/gif2hdf.c
parent953a75e4f164e881a145ca669f1ec34dd1357d05 (diff)
downloadhdf5-e685336ab13081f8e4a92b7a4a9b6bf022ae5b23.zip
hdf5-e685336ab13081f8e4a92b7a4a9b6bf022ae5b23.tar.gz
hdf5-e685336ab13081f8e4a92b7a4a9b6bf022ae5b23.tar.bz2
[svn-r4254]
Purpose: Reformatting Description: Reformatted the code so that it's much clearer and conforms to the HDF5 coding standards. Changed the function headers to use the ANSI style instead of the KnR style. Kept the use of typedef's such as "unsigned char" being "BYTE" and so on since of of this code is copied from some other place and that's the style they use...I didn't want to break things. Platforms tested: It compiles fine on Linux, but there aren't any tests for this package, so...
Diffstat (limited to 'tools/gifconv/gif2hdf.c')
-rw-r--r--tools/gifconv/gif2hdf.c213
1 files changed, 108 insertions, 105 deletions
diff --git a/tools/gifconv/gif2hdf.c b/tools/gifconv/gif2hdf.c
index 6b4ae2b..89edb5f 100644
--- a/tools/gifconv/gif2hdf.c
+++ b/tools/gifconv/gif2hdf.c
@@ -1,113 +1,116 @@
-/* #include <hdf.h> */
-#include "gif.h"
+/*
+ * Copyright (C) 2001 National Center for Supercomputing Applications
+ * All rights reserved.
+ */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include "gif.h"
+
int
main(int argv , char *argc[])
{
-
- GIFTOMEM GifMemoryStruct;
- GIFIMAGEDESC gifImageDesc;
-
- FILE *fpGif;
-
- /* replacing int32 with long */
- long i,ImageCount;
- long filesize;
-
- BYTE *MemGif;
- BYTE *StartPos;
-
- /* VSNAMELENMAX is a carryover from HDF4 and is #defined to 256 in gif.h */
- char GIFFileName[VSNAMELENMAX];
- char HDFFileName[VSNAMELENMAX];
-
- /* Initialize all GifMemoryStruct pointers to null
- ** to prevent hassles later on
- */
- GifMemoryStruct.GifHeader = NULL;
- GifMemoryStruct.GifImageDesc = NULL;
- GifMemoryStruct.GifGraphicControlExtension = NULL;
- GifMemoryStruct.GifPlainTextExtension = NULL;
- GifMemoryStruct.GifApplicationExtension = NULL;
- GifMemoryStruct.GifCommentExtension = NULL;
-
-
- if (argv<3)
- {
- printf("\n\nWrong Usage. Use:\ngif2hdf <GIFFILE> <HDFFILE>\n\n");
- return(-1);
- }
-
-
-
- strncpy(GIFFileName , argc[1] , VSNAMELENMAX - 1);
- strncpy(HDFFileName , argc[2] , VSNAMELENMAX - 1);
- GIFFileName[VSNAMELENMAX - 1] = '\0';
- HDFFileName[VSNAMELENMAX - 1] = '\0';
-
- if (!(fpGif = fopen(GIFFileName,"rb"))) {
- printf("Unable to open GIF file for reading.\n");
- printf("Filename (including path) must be less than %d charachters in length\n",VSNAMELENMAX);
- exit(-1);
- }
-
- /* Get the whole file into memory. Mem's much faster than I/O */
- fseek(fpGif, 0L , 2);
- filesize = ftell(fpGif);
- fseek(fpGif, 0L , 0);
- if (filesize == 0) printf("File Size Zero");
- if (!(MemGif = StartPos = (BYTE *)malloc((size_t)filesize))) {
- printf("Out of memory");
- exit (-1);
- }
- if (fread(MemGif,(size_t)filesize,1,fpGif) != 1) {
- printf("Corrupted Input File");
- exit(-1);
- }
-
- fseek(fpGif,0L,0);
-
- /*
- ** Call Gif2Mem and break the whole file into parts.
- ** Gif2Mem also calls decompresses the images so we don't
- ** have to worry about that
- */
- GifMemoryStruct = Gif2Mem(MemGif);
- if (ferror(fpGif)) {
- printf("File Stream Error\n\n");
- exit(-1);
- }
- fclose(fpGif);
-
- /* Call WriteHDF from here. Go ahead and change WriteHDF to write
- ** whatever format you want
- */
- if (WriteHDF(GifMemoryStruct , argc[2] , argc[1]))
- printf("HDF Write Error\n\n");
-
- /* Free all buffers */
- /* replacing int32 with long */
- ImageCount = (long)((GifMemoryStruct.GifHeader)->ImageCount);
-
- for(i = 0 ; i < ImageCount ; i++)
- {
- gifImageDesc = *(GifMemoryStruct.GifImageDesc[i]);
- if (gifImageDesc.Image != NULL)
- free(gifImageDesc.Image);
-
- if (GifMemoryStruct.GifGraphicControlExtension[i] != NULL)
- free(GifMemoryStruct.GifGraphicControlExtension[i]);
-
- }
- free(StartPos);
-
- free (GifMemoryStruct.GifHeader);
-
- if (GifMemoryStruct.GifApplicationExtension != NULL)
- free (GifMemoryStruct.GifApplicationExtension);
-
- return (0);
+ GIFTOMEM GifMemoryStruct;
+ GIFIMAGEDESC gifImageDesc;
+
+ FILE *fpGif;
+
+ /* replacing int32 with long */
+ long i, ImageCount;
+ long filesize;
+
+ BYTE *MemGif;
+ BYTE *StartPos;
+
+ /* VSNAMELENMAX is a carryover from HDF4 and is #defined to 256 in gif.h */
+ char GIFFileName[VSNAMELENMAX];
+ char HDFFileName[VSNAMELENMAX];
+
+ /*
+ * Initialize all GifMemoryStruct pointers to null to prevent hassles
+ * later on
+ */
+ GifMemoryStruct.GifHeader = NULL;
+ GifMemoryStruct.GifImageDesc = NULL;
+ GifMemoryStruct.GifGraphicControlExtension = NULL;
+ GifMemoryStruct.GifPlainTextExtension = NULL;
+ GifMemoryStruct.GifApplicationExtension = NULL;
+ GifMemoryStruct.GifCommentExtension = NULL;
+
+ if (argv < 3) {
+ printf("\n\nWrong Usage. Use:\ngif2hdf <GIFFILE> <HDFFILE>\n\n");
+ return(-1);
+ }
+
+ strncpy(GIFFileName , argc[1] , VSNAMELENMAX - 1);
+ strncpy(HDFFileName , argc[2] , VSNAMELENMAX - 1);
+ GIFFileName[VSNAMELENMAX - 1] = '\0';
+ HDFFileName[VSNAMELENMAX - 1] = '\0';
+
+ if (!(fpGif = fopen(GIFFileName,"rb"))) {
+ printf("Unable to open GIF file for reading.\n");
+ printf("Filename (including path) must be less than %d charachters in length\n",
+ VSNAMELENMAX);
+ exit(-1);
+ }
+
+ /* Get the whole file into memory. Mem's much faster than I/O */
+ fseek(fpGif, 0L , 2);
+ filesize = ftell(fpGif);
+ fseek(fpGif, 0L , 0);
+
+ if (filesize == 0)
+ printf("File Size Zero");
+
+ if (!(MemGif = StartPos = (BYTE *)malloc((size_t)filesize))) {
+ printf("Out of memory");
+ exit (-1);
+ }
+
+ if (fread(MemGif,(size_t)filesize,1,fpGif) != 1) {
+ printf("Corrupted Input File");
+ exit(-1);
+ }
+
+ fseek(fpGif,0L,0);
+
+ /*
+ * Call Gif2Mem and break the whole file into parts. Gif2Mem also calls
+ * decompresses the images so we don't have to worry about that
+ */
+ GifMemoryStruct = Gif2Mem(MemGif);
+
+ if (ferror(fpGif)) {
+ printf("File Stream Error\n\n");
+ exit(-1);
+ }
+
+ fclose(fpGif);
+
+ /*
+ * Call WriteHDF from here. Go ahead and change WriteHDF to write whatever
+ * format you want
+ */
+ if (WriteHDF(GifMemoryStruct , argc[2] , argc[1]))
+ printf("HDF Write Error\n\n");
+
+ /* Free all buffers */
+ /* replacing int32 with long */
+ ImageCount = (long)((GifMemoryStruct.GifHeader)->ImageCount);
+
+ for(i = 0; i < ImageCount ; i++) {
+ gifImageDesc = *(GifMemoryStruct.GifImageDesc[i]);
+
+ if (gifImageDesc.Image != NULL)
+ free(gifImageDesc.Image);
+
+ if (GifMemoryStruct.GifGraphicControlExtension[i] != NULL)
+ free(GifMemoryStruct.GifGraphicControlExtension[i]);
+ }
+
+ free(StartPos);
+ free(GifMemoryStruct.GifHeader);
+ free(GifMemoryStruct.GifApplicationExtension);
+ return 0;
}