+ /* Open a temporary file to uncompress the contents */
+ FILE *infile = tmpfile ();
+ if (infile == NULL)
+ {
+ fprintf (stderr, ERROR_READING_FILE);
+ exit (1);
+ }
+ /* Put the uncompressed content to the temp file */
+ char buf[4096];
+ while (gzread (insourcefile, buf, 4096))
+ {
+ int res = fwrite (buf, sizeof(char), strlen (buf), infile);
+ if (res == 0)
+ {
+ fprintf (stderr, ERROR_READING_FILE);
+ fclose (infile);
+ gzclose (insourcefile);
+ exit (1);
+ }
+ }
+ /* Close the gzip file */
+ gzclose (insourcefile);
+ /* Flush the temp file buffer and rewind to beginning */
+ fflush (infile);
+ fseek (infile, 0, 0);
+
+ /* Read the temporary file contents to the structure Puzzle */
+ Puzzle p;