- FILE *file = fopen (filename, "w");
- char app[256], str[256]="", def_name[64] ;
- int count = image->size, col=0;
- unsigned char *dataptr = image->data ;
- if (file==NULL)
- return -1 ;
-
-/* Author information */
- fprintf(file, "/*\n * Generated by EasyLogo, (C) 2000 by Paolo Scaffardi\n *\n");
- fprintf(file, " * To use this, include it and call: easylogo_plot(screen,&%s, width,x,y)\n *\n", varname);
- fprintf(file, " * Where:\t'screen'\tis the pointer to the frame buffer\n");
- fprintf(file, " *\t\t'width'\tis the screen width\n");
- fprintf(file, " *\t\t'x'\t\tis the horizontal position\n");
- fprintf(file, " *\t\t'y'\t\tis the vertical position\n */\n\n");
-
-/* Headers */
- fprintf(file, "#include <video_easylogo.h>\n\n");
-/* Macros */
- strcpy(def_name, varname);
+ FILE *file = fopen (filename, "w");
+ char app[256], str[256] = "", def_name[64];
+ int count = image->size, col = 0;
+ unsigned char *dataptr = image->data;
+
+ if (file == NULL)
+ return -1;
+
+ /* Author information */
+ fprintf (file,
+ "/*\n * Generated by EasyLogo, (C) 2000 by Paolo Scaffardi\n *\n");
+ fprintf (file,
+ " * To use this, include it and call: easylogo_plot(screen,&%s, width,x,y)\n *\n",
+ varname);
+ fprintf (file,
+ " * Where:\t'screen'\tis the pointer to the frame buffer\n");
+ fprintf (file, " *\t\t'width'\tis the screen width\n");
+ fprintf (file, " *\t\t'x'\t\tis the horizontal position\n");
+ fprintf (file, " *\t\t'y'\t\tis the vertical position\n */\n\n");
+
+ /* gzip compress */
+ if (use_gzip & 0x1) {
+ const char *errstr = NULL;
+ unsigned char *compressed;
+ struct stat st;
+ FILE *gz;
+ char *gzfilename = xmalloc(strlen (filename) + 20);
+ char *gzcmd = xmalloc(strlen (filename) + 20);
+
+ sprintf (gzfilename, "%s.gz", filename);
+ sprintf (gzcmd, "gzip > %s", gzfilename);
+ gz = popen (gzcmd, "w");
+ if (!gz) {
+ errstr = "\nerror: popen() failed";
+ goto done;
+ }
+ if (fwrite (image->data, image->size, 1, gz) != 1) {
+ errstr = "\nerror: writing data to gzip failed";
+ goto done;
+ }
+ if (pclose (gz)) {
+ errstr = "\nerror: gzip process failed";
+ goto done;
+ }
+
+ gz = fopen (gzfilename, "r");
+ if (!gz) {
+ errstr = "\nerror: open() on gzip data failed";
+ goto done;
+ }
+ if (stat (gzfilename, &st)) {
+ errstr = "\nerror: stat() on gzip file failed";
+ goto done;
+ }
+ compressed = xmalloc (st.st_size);
+ if (fread (compressed, st.st_size, 1, gz) != 1) {
+ errstr = "\nerror: reading gzip data failed";
+ goto done;
+ }
+ fclose (gz);
+
+ unlink (gzfilename);
+
+ dataptr = compressed;
+ count = st.st_size;
+ fprintf (file, "#define EASYLOGO_ENABLE_GZIP %i\n\n", count);
+ if (use_gzip & 0x2)
+ fprintf (file, "static unsigned char EASYLOGO_DECOMP_BUFFER[%i];\n\n", image->size);
+
+ done:
+ free (gzfilename);
+ free (gzcmd);
+
+ if (errstr) {
+ perror (errstr);
+ return -1;
+ }
+ }
+
+ /* Headers */
+ fprintf (file, "#include <video_easylogo.h>\n\n");
+ /* Macros */
+ strcpy (def_name, varname);