[gimp] plug-ins: update public FLI functions to add a GError and return gboolean



commit 317e0ca21ee4b93a6049a8db90e746b300d5e529
Author: Jacob Boerema <jgboerema gmail com>
Date:   Sat May 7 17:02:17 2022 -0400

    plug-ins: update public FLI functions to add a GError and return gboolean
    
    Improvements to the FLI loading and exporting plug-in:
    - I added a GError parameter to all public read/write functions.
    - All public functions now return a gboolean result to show if they
    succeeded or failed. Before most functions were void. For the non void
    returns (the two fli_write_color functions) I added a gboolean
    parameter.
    - Do cleanup if we fail to read a frame. If at least one frame was read
    successfully, we will keep the incomplete image/animation.
    - Change name of layer to include the delay in ms.

 plug-ins/file-fli/fli-gimp.c |  73 +++++++++++----
 plug-ins/file-fli/fli.c      | 211 +++++++++++++++++++++++++++++++------------
 plug-ins/file-fli/fli.h      | 154 +++++++++++++++++--------------
 3 files changed, 295 insertions(+), 143 deletions(-)
---
diff --git a/plug-ins/file-fli/fli-gimp.c b/plug-ins/file-fli/fli-gimp.c
index a477b7eb51..a290344173 100644
--- a/plug-ins/file-fli/fli-gimp.c
+++ b/plug-ins/file-fli/fli-gimp.c
@@ -460,7 +460,11 @@ get_info (GFile   *file,
       return FALSE;
     }
 
-  fli_read_header (fp, &fli_header);
+  if (! fli_read_header (fp, &fli_header, error))
+    {
+      fclose (fp);
+      return FALSE;
+    }
   fclose (fp);
 
   *width  = fli_header.width;
@@ -507,16 +511,13 @@ load_image (GFile    *file,
       return NULL;
     }
 
-  fli_read_header (fp, &fli_header);
-  if (fli_header.magic == NO_HEADER)
+  if (! fli_read_header (fp, &fli_header, error))
     {
       fclose (fp);
       return NULL;
     }
-  else
-    {
-      fseek (fp, 128, SEEK_SET);
-    }
+
+  fseek (fp, 128, SEEK_SET);
 
   /*
    * Fix parameters
@@ -568,7 +569,13 @@ load_image (GFile    *file,
    */
   for (cnt = 1; cnt < from_frame; cnt++)
     {
-      fli_read_frame (fp, &fli_header, ofb, ocm, fb, cm);
+      if (! fli_read_frame (fp, &fli_header, ofb, ocm, fb, cm, error))
+        {
+          fclose (fp);
+          g_free (fb);
+          g_free (ofb);
+          return FALSE;
+        }
       memcpy (ocm, cm, 768);
       fb_x = fb; fb = ofb; ofb = fb_x;
     }
@@ -577,7 +584,9 @@ load_image (GFile    *file,
    */
   for (cnt = from_frame; cnt <= to_frame; cnt++)
     {
-      gchar *name_buf = g_strdup_printf (_("Frame (%i)"), cnt);
+      gchar *name_buf = g_strdup_printf (_("Frame %d (%ums)"), cnt, fli_header.speed);
+
+      g_debug ("Loading frame %d", cnt);
 
       layer = gimp_layer_new (image, name_buf,
                               fli_header.width, fli_header.height,
@@ -586,9 +595,31 @@ load_image (GFile    *file,
                               gimp_image_get_default_new_layer_mode (image));
       g_free (name_buf);
 
-      buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
+      if (! fli_read_frame (fp, &fli_header, ofb, ocm, fb, cm, error))
+        {
+          /* Since some of the frames could have been read, let's not make
+           * this fatal, unless it's the first frame. */
+          if (error && *error)
+            {
+              gimp_item_delete (GIMP_ITEM(layer));
+              if (cnt > from_frame)
+                {
+                  g_warning ("Failed to read frame %d. Possibly corrupt animation.\n%s",
+                              cnt, (*error)->message);
+                  g_clear_error (error);
+                }
+              else
+                {
+                  gimp_image_delete (image);
+                  g_prefix_error (error, _("Failed to read frame %d. Possibly corrupt animation.\n"), cnt);
+                  return FALSE;
+                }
+            }
+
+          break;
+        }
 
-      fli_read_frame (fp, &fli_header, ofb, ocm, fb, cm);
+      buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
 
       gegl_buffer_set (buffer, GEGL_RECTANGLE (0, 0,
                                                fli_header.width,
@@ -608,7 +639,8 @@ load_image (GFile    *file,
           fb_x = fb; fb = ofb; ofb = fb_x;
         }
 
-      gimp_progress_update ((double) cnt + 1 / (double)(to_frame - from_frame));
+      if (to_frame > from_frame)
+        gimp_progress_update ((double) cnt + 1 / (double)(to_frame - from_frame));
     }
 
   gimp_image_set_colormap (image, cm, 256);
@@ -655,6 +687,7 @@ save_image (GFile      *file,
   gint          cnt;
   gint          from_frame;
   gint          to_frame;
+  gboolean      write_ok = FALSE;
 
   g_object_get (config,
                 "from-frame", &from_frame,
@@ -738,7 +771,10 @@ save_image (GFile      *file,
       break;
 
     default:
-      g_message (_("Sorry, I can export only INDEXED and GRAY images."));
+      /* Not translating this, since we should never get this error, unless
+       * someone messed up setting supported image types. */
+      g_set_error (error, GIMP_PLUG_IN_ERROR, 0,
+                   "Exporting of RGB images is not supported!");
       return FALSE;
     }
 
@@ -845,13 +881,15 @@ save_image (GFile      *file,
       if (cnt > from_frame)
         {
           /* save frame, allow all codecs */
-          fli_write_frame (fp, &fli_header, ofb, cm, fb, cm, W_ALL);
+          write_ok = fli_write_frame (fp, &fli_header, ofb, cm, fb, cm, W_ALL, error);
         }
       else
         {
           /* save first frame, no delta information, allow all codecs */
-          fli_write_frame (fp, &fli_header, NULL, NULL, fb, cm, W_ALL);
+          write_ok = fli_write_frame (fp, &fli_header, NULL, NULL, fb, cm, W_ALL, error);
         }
+      if (! write_ok)
+        break;
 
       if (cnt < to_frame)
         memcpy (ofb, fb, fli_header.width * fli_header.height);
@@ -862,7 +900,8 @@ save_image (GFile      *file,
   /*
    * finish fli
    */
-  fli_write_header (fp, &fli_header);
+  if (write_ok)
+    write_ok = fli_write_header (fp, &fli_header, error);
   fclose (fp);
 
   g_free (fb);
@@ -871,7 +910,7 @@ save_image (GFile      *file,
 
   gimp_progress_update (1.0);
 
-  return TRUE;
+  return write_ok;
 }
 
 /*
diff --git a/plug-ins/file-fli/fli.c b/plug-ins/file-fli/fli.c
index c5d7b64b22..2fbc8e121d 100644
--- a/plug-ins/file-fli/fli.c
+++ b/plug-ins/file-fli/fli.c
@@ -27,8 +27,12 @@
 
 #include <glib/gstdio.h>
 
+#include <libgimp/gimp.h>
+
 #include "fli.h"
 
+#include "libgimp/stdplugins-intl.h"
+
 /*
  * To avoid endian-problems I wrote these functions:
  */
@@ -91,9 +95,10 @@ fli_write_uint32 (FILE    *f,
   fwrite (&b, 1, 4, f);
 }
 
-void
-fli_read_header (FILE         *f,
-                 s_fli_header *fli_header)
+gboolean
+fli_read_header (FILE          *f,
+                 s_fli_header  *fli_header,
+                 GError       **error)
 {
   fli_header->filesize = fli_read_uint32 (f);  /* 0 */
   fli_header->magic    = fli_read_short (f);   /* 4 */
@@ -117,8 +122,10 @@ fli_read_header (FILE         *f,
         }
       else
         {
-          fprintf (stderr, "error: magic number is wrong !\n");
           fli_header->magic = NO_HEADER;
+          g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                       _("Invalid header: not a FLI/FLC animation!"));
+          return FALSE;
         }
     }
 
@@ -127,11 +134,14 @@ fli_read_header (FILE         *f,
 
   if (fli_header->height == 0)
     fli_header->height = 200;
+
+  return TRUE;
 }
 
-void
-fli_write_header (FILE         *f,
-                  s_fli_header *fli_header)
+gboolean
+fli_write_header (FILE          *f,
+                  s_fli_header  *fli_header,
+                  GError       **error)
 {
   fli_header->filesize = ftell (f);
   fseek (f, 0, SEEK_SET);
@@ -159,18 +169,23 @@ fli_write_header (FILE         *f,
         }
       else
         {
-          fprintf (stderr, "error: magic number in header is wrong !\n");
+          g_set_error (error, GIMP_PLUG_IN_ERROR, 0,
+                       _("Invalid header: magic number is wrong!"));
+          return FALSE;
         }
     }
+
+  return TRUE;
 }
 
-void
+gboolean
 fli_read_frame (FILE          *f,
                 s_fli_header  *fli_header,
                 guchar        *old_framebuf,
                 guchar        *old_cmap,
                 guchar        *framebuf,
-                guchar        *cmap)
+                guchar        *cmap,
+                GError       **error)
 {
   s_fli_frame   fli_frame;
   guint64       framepos;
@@ -182,6 +197,16 @@ fli_read_frame (FILE          *f,
   fli_frame.magic  = fli_read_short (f);
   fli_frame.chunks = fli_read_short (f);
 
+  g_debug ("Frame size: %u, magic: %x, chunks: %u\n",
+           fli_frame.size, fli_frame.magic, fli_frame.chunks);
+
+  if (framepos + fli_frame.size >= fli_header->filesize)
+    {
+      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                   _("Invalid frame size points past end of file!"));
+      return FALSE;
+    }
+
   if (fli_frame.magic == FRAME)
     {
       fseek (f, framepos + 16, SEEK_SET);
@@ -189,32 +214,34 @@ fli_read_frame (FILE          *f,
         {
           s_fli_chunk  chunk;
           guint32      chunkpos;
+          gboolean     read_ok;
 
           chunkpos = ftell (f);
           chunk.size = fli_read_uint32 (f);
           chunk.magic = fli_read_short (f);
+          read_ok = TRUE;
           switch (chunk.magic)
             {
             case FLI_COLOR:
-              fli_read_color (f, fli_header, old_cmap, cmap);
+              read_ok = fli_read_color (f, fli_header, old_cmap, cmap, error);
               break;
             case FLI_COLOR_2:
-              fli_read_color_2 (f, fli_header, old_cmap, cmap);
+              read_ok = fli_read_color_2 (f, fli_header, old_cmap, cmap, error);
               break;
             case FLI_BLACK:
-              fli_read_black (f, fli_header, framebuf);
+              read_ok = fli_read_black (f, fli_header, framebuf, error);
               break;
             case FLI_BRUN:
-              fli_read_brun (f, fli_header, framebuf);
+              read_ok = fli_read_brun (f, fli_header, framebuf, error);
               break;
             case FLI_COPY:
-              fli_read_copy (f, fli_header, framebuf);
+              read_ok = fli_read_copy (f, fli_header, framebuf, error);
               break;
             case FLI_LC:
-              fli_read_lc (f, fli_header, old_framebuf, framebuf);
+              read_ok = fli_read_lc (f, fli_header, old_framebuf, framebuf, error);
               break;
             case FLI_LC_2:
-              fli_read_lc_2 (f, fli_header, old_framebuf, framebuf);
+              read_ok = fli_read_lc_2 (f, fli_header, old_framebuf, framebuf, error);
               break;
             case FLI_MINI:
               /* unused, skip */
@@ -223,6 +250,9 @@ fli_read_frame (FILE          *f,
               /* unknown, skip */
               break;
             }
+          if (! read_ok)
+            return FALSE;
+
           if (chunk.size & 1)
             chunk.size++;
           fseek (f, chunkpos + chunk.size, SEEK_SET);
@@ -231,16 +261,19 @@ fli_read_frame (FILE          *f,
   /* else: unknown, skip */
 
   fseek (f, framepos + fli_frame.size, SEEK_SET);
+
+  return TRUE;
 }
 
-void
+gboolean
 fli_write_frame (FILE          *f,
                  s_fli_header  *fli_header,
                  guchar        *old_framebuf,
                  guchar        *old_cmap,
                  guchar        *framebuf,
                  guchar        *cmap,
-                 gushort        codec_mask)
+                 gushort        codec_mask,
+                 GError       **error)
 {
   s_fli_frame  fli_frame;
   guint32      framepos, frameend;
@@ -267,19 +300,39 @@ fli_write_frame (FILE          *f,
    */
   if (fli_header->magic == HEADER_FLI)
     {
-      if (fli_write_color (f, fli_header, old_cmap, cmap))
-        fli_frame.chunks++;
+      gboolean more = FALSE;
+
+      if (fli_write_color (f, fli_header, old_cmap, cmap, &more, error))
+        {
+          if (more)
+            fli_frame.chunks++;
+        }
+      else
+        {
+          return FALSE;
+        }
     }
   else
     {
       if (fli_header->magic == HEADER_FLC)
         {
-          if (fli_write_color_2 (f, fli_header, old_cmap, cmap))
-            fli_frame.chunks++;
+          gboolean more = FALSE;
+
+          if (fli_write_color_2 (f, fli_header, old_cmap, cmap, &more, error))
+            {
+              if (more)
+                fli_frame.chunks++;
+            }
+          else
+            {
+              return FALSE;
+            }
         }
       else
         {
-          fprintf (stderr, "error: magic number in header is wrong !\n");
+          g_set_error (error, GIMP_PLUG_IN_ERROR, 0,
+                       _("Invalid header: magic number is wrong!"));
+          return FALSE;
         }
     }
 
@@ -298,11 +351,13 @@ fli_write_frame (FILE          *f,
   /* create bitmap chunk */
   if (old_framebuf == NULL)
     {
-      fli_write_brun (f, fli_header, framebuf);
+      if (! fli_write_brun (f, fli_header, framebuf, error))
+        return FALSE;
     }
   else
     {
-      fli_write_lc (f, fli_header, old_framebuf, framebuf);
+      if (! fli_write_lc (f, fli_header, old_framebuf, framebuf, error))
+        return FALSE;
     }
   fli_frame.chunks++;
 
@@ -314,16 +369,19 @@ fli_write_frame (FILE          *f,
   fli_write_short (f, fli_frame.chunks);
   fseek (f, frameend, SEEK_SET);
   fli_header->frames++;
+
+  return TRUE;
 }
 
 /*
  * palette chunks from the classical Autodesk Animator.
  */
-void
+gboolean
 fli_read_color (FILE          *f,
                 s_fli_header  *fli_header,
                 guchar        *old_cmap,
-                guchar        *cmap)
+                guchar        *cmap,
+                GError       **error)
 {
   gushort num_packets, cnt_packets, col_pos;
 
@@ -341,7 +399,7 @@ fli_read_color (FILE          *f,
             {
               cmap[col_pos] = fli_read_char (f) << 2;
             }
-          return;
+          return TRUE;
         }
       for (col_cnt = skip_col; (col_cnt > 0) && (col_pos < 768); col_cnt--)
         {
@@ -356,18 +414,23 @@ fli_read_color (FILE          *f,
           cmap[col_pos++] = fli_read_char (f) << 2;
         }
     }
+
+  return TRUE;
 }
 
-int
+gboolean
 fli_write_color (FILE          *f,
                  s_fli_header  *fli_header,
                  guchar        *old_cmap,
-                 guchar        *cmap)
+                 guchar        *cmap,
+                 gboolean      *more,
+                 GError       **error)
 {
   guint32       chunkpos;
   gushort       num_packets;
   s_fli_chunk   chunk;
 
+  *more = FALSE;
   chunkpos = ftell (f);
   fseek (f, chunkpos + 8, SEEK_SET);
   num_packets = 0;
@@ -440,21 +503,23 @@ fli_write_color (FILE          *f,
         chunk.size++;
 
       fseek (f, chunkpos + chunk.size, SEEK_SET);
-      return 1;
+      *more = TRUE;
+      return TRUE;
     }
 
   fseek (f, chunkpos, SEEK_SET);
-  return 0;
+  return TRUE;
 }
 
 /*
  * palette chunks from Autodesk Animator pro
  */
-void
+gboolean
 fli_read_color_2 (FILE          *f,
                   s_fli_header  *fli_header,
                   guchar        *old_cmap,
-                  guchar        *cmap)
+                  guchar        *cmap,
+                  GError       **error)
 {
   gushort num_packets, cnt_packets, col_pos;
 
@@ -472,7 +537,7 @@ fli_read_color_2 (FILE          *f,
             {
               cmap[col_pos] = fli_read_char (f);
             }
-          return;
+          return TRUE;
         }
       for (col_cnt = skip_col; (col_cnt > 0) && (col_pos < 768); col_cnt--)
         {
@@ -490,18 +555,23 @@ fli_read_color_2 (FILE          *f,
           cmap[col_pos++] = fli_read_char (f);
         }
     }
+
+  return TRUE;
 }
 
-int
+gboolean
 fli_write_color_2 (FILE          *f,
                    s_fli_header  *fli_header,
                    guchar        *old_cmap,
-                   guchar        *cmap)
+                   guchar        *cmap,
+                   gboolean      *more,
+                   GError       **error)
 {
   guint32       chunkpos;
   gushort       num_packets;
   s_fli_chunk   chunk;
 
+  *more = FALSE;
   chunkpos = ftell (f);
   fseek (f, chunkpos + 8, SEEK_SET);
   num_packets = 0;
@@ -571,27 +641,33 @@ fli_write_color_2 (FILE          *f,
       if (chunk.size & 1)
         chunk.size++;
       fseek (f, chunkpos + chunk.size, SEEK_SET);
-      return 1;
+      *more = TRUE;
+      return TRUE;
     }
   fseek (f, chunkpos, SEEK_SET);
-  return 0;
+
+  return TRUE;
 }
 
 /*
  * completely black frame
  */
-void
+gboolean
 fli_read_black (FILE          *f,
                 s_fli_header  *fli_header,
-                guchar        *framebuf)
+                guchar        *framebuf,
+                GError       **error)
 {
   memset (framebuf, 0, fli_header->width * fli_header->height);
+
+  return TRUE;
 }
 
-void
+gboolean
 fli_write_black (FILE          *f,
                  s_fli_header  *fli_header,
-                 guchar        *framebuf)
+                 guchar        *framebuf,
+                 GError       **error)
 {
   s_fli_chunk chunk;
 
@@ -600,23 +676,29 @@ fli_write_black (FILE          *f,
 
   fli_write_uint32 (f, chunk.size);
   fli_write_short (f, chunk.magic);
+
+  return TRUE;
 }
 
 /*
  * Uncompressed frame
  */
-void
+gboolean
 fli_read_copy (FILE          *f,
                s_fli_header  *fli_header,
-               guchar        *framebuf)
+               guchar        *framebuf,
+               GError       **error)
 {
   fread (framebuf, fli_header->width, fli_header->height, f);
+
+  return TRUE;
 }
 
-void
+gboolean
 fli_write_copy (FILE          *f,
                 s_fli_header  *fli_header,
-                guchar        *framebuf)
+                guchar        *framebuf,
+                GError       **error)
 {
   guint32      chunkpos;
   s_fli_chunk  chunk;
@@ -634,15 +716,17 @@ fli_write_copy (FILE          *f,
   if (chunk.size & 1)
     chunk.size++;
   fseek (f, chunkpos + chunk.size, SEEK_SET);
+  return TRUE;
 }
 
 /*
  * This is a RLE algorithm, used for the first image of an animation
  */
-void
+gboolean
 fli_read_brun (FILE          *f,
                s_fli_header  *fli_header,
-               guchar        *framebuf)
+               guchar        *framebuf,
+               GError       **error)
 {
   gushort  yc;
   guchar  *pos;
@@ -682,12 +766,14 @@ fli_read_brun (FILE          *f,
             }
         }
     }
+  return TRUE;
 }
 
-void
+gboolean
 fli_write_brun (FILE          *f,
                 s_fli_header  *fli_header,
-                guchar        *framebuf)
+                guchar        *framebuf,
+                GError       **error)
 {
   guint32       chunkpos;
   s_fli_chunk   chunk;
@@ -766,6 +852,7 @@ fli_write_brun (FILE          *f,
   if (chunk.size & 1)
     chunk.size++;
   fseek (f, chunkpos + chunk.size, SEEK_SET);
+  return TRUE;
 }
 
 /*
@@ -775,11 +862,12 @@ fli_write_brun (FILE          *f,
  * image, and unchanged pixels in a line. This chunk is used in FLI
  * files.
  */
-void
+gboolean
 fli_read_lc (FILE          *f,
              s_fli_header  *fli_header,
              guchar        *old_framebuf,
-             guchar        *framebuf)
+             guchar        *framebuf,
+             GError       **error)
 {
   gushort  yc, firstline, numline;
   guchar  *pos;
@@ -788,7 +876,7 @@ fli_read_lc (FILE          *f,
   firstline = fli_read_short (f);
   numline = fli_read_short (f);
   if (numline > fli_header->height || fli_header->height - numline < firstline)
-    return;
+    return TRUE;
 
   for (yc = 0; yc < numline; yc++)
     {
@@ -827,13 +915,15 @@ fli_read_lc (FILE          *f,
             }
         }
     }
+  return TRUE;
 }
 
-void
+gboolean
 fli_write_lc (FILE          *f,
               s_fli_header  *fli_header,
               guchar        *old_framebuf,
-              guchar        *framebuf)
+              guchar        *framebuf,
+              GError       **error)
 {
   guint32       chunkpos;
   s_fli_chunk   chunk;
@@ -953,6 +1043,7 @@ fli_write_lc (FILE          *f,
   if (chunk.size & 1)
     chunk.size++;
   fseek (f, chunkpos + chunk.size, SEEK_SET);
+  return TRUE;
 }
 
 
@@ -962,11 +1053,12 @@ fli_write_lc (FILE          *f,
  * skipping larger parts of the image. This chunk is used in FLC
  * files.
  */
-void
+gboolean
 fli_read_lc_2 (FILE          *f,
                s_fli_header  *fli_header,
                guchar        *old_framebuf,
-               guchar        *framebuf)
+               guchar        *framebuf,
+               GError       **error)
 {
   gushort  yc, lc, numline;
   guchar  *pos;
@@ -1032,4 +1124,5 @@ fli_read_lc_2 (FILE          *f,
         pos[xc] = lpn;
       yc++;
     }
+  return TRUE;
 }
diff --git a/plug-ins/file-fli/fli.h b/plug-ins/file-fli/fli.h
index 5d5913bd12..84c31a203b 100644
--- a/plug-ins/file-fli/fli.h
+++ b/plug-ins/file-fli/fli.h
@@ -79,76 +79,96 @@ typedef struct _fli_chunk
 #define W_ALL           0xFFFF
 
 /** functions */
-void fli_read_header   (FILE          *f,
-                        s_fli_header  *fli_header);
+gboolean fli_read_header     (FILE          *f,
+                              s_fli_header  *fli_header,
+                              GError       **error);
 
-void fli_read_frame    (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *old_framebuf,
-                        guchar        *old_cmap,
-                        guchar        *framebuf,
-                        guchar        *cmap);
+gboolean fli_read_frame      (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *old_framebuf,
+                              guchar        *old_cmap,
+                              guchar        *framebuf,
+                              guchar        *cmap,
+                              GError       **error);
 
-void fli_read_color    (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *old_cmap,
-                        guchar        *cmap);
-void fli_read_color_2  (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *old_cmap,
-                        guchar        *cmap);
-void fli_read_black    (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *framebuf);
-void fli_read_brun     (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *framebuf);
-void fli_read_copy     (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *framebuf);
-void fli_read_lc       (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *old_framebuf,
-                        guchar        *framebuf);
-void fli_read_lc_2     (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *old_framebuf,
-                        guchar        *framebuf);
+gboolean fli_read_color      (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *old_cmap,
+                              guchar        *cmap,
+                              GError       **error);
+gboolean fli_read_color_2    (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *old_cmap,
+                              guchar        *cmap,
+                              GError       **error);
+gboolean fli_read_black      (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *framebuf,
+                              GError       **error);
+gboolean fli_read_brun       (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *framebuf,
+                              GError       **error);
+gboolean fli_read_copy       (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *framebuf,
+                              GError       **error);
+gboolean fli_read_lc         (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *old_framebuf,
+                              guchar        *framebuf,
+                              GError       **error);
+gboolean fli_read_lc_2       (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *old_framebuf,
+                              guchar        *framebuf,
+                              GError       **error);
 
-void fli_write_header  (FILE          *f,
-                        s_fli_header  *fli_header);
-void fli_write_frame   (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *old_framebuf,
-                        guchar        *old_cmap,
-                        guchar        *framebuf,
-                        guchar        *cmap,
-                        gushort        codec_mask);
+gboolean fli_write_header    (FILE          *f,
+                              s_fli_header  *fli_header,
+                              GError       **error);
+gboolean fli_write_frame     (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *old_framebuf,
+                              guchar        *old_cmap,
+                              guchar        *framebuf,
+                              guchar        *cmap,
+                              gushort        codec_mask,
+                              GError       **error);
 
-int  fli_write_color   (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *old_cmap,
-                        guchar        *cmap);
-int  fli_write_color_2 (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *old_cmap,
-                        guchar        *cmap);
-void fli_write_black   (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *framebuf);
-void fli_write_brun    (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *framebuf);
-void fli_write_copy    (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *framebuf);
-void fli_write_lc      (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *old_framebuf,
-                        guchar        *framebuf);
-void fli_write_lc_2    (FILE          *f,
-                        s_fli_header  *fli_header,
-                        guchar        *old_framebuf,
-                        guchar        *framebuf);
+gboolean  fli_write_color    (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *old_cmap,
+                              guchar        *cmap,
+                              gboolean      *more,
+                              GError       **error);
+gboolean  fli_write_color_2  (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *old_cmap,
+                              guchar        *cmap,
+                              gboolean      *more,
+                              GError       **error);
+gboolean fli_write_black     (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *framebuf,
+                              GError       **error);
+gboolean fli_write_brun      (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *framebuf,
+                              GError       **error);
+gboolean fli_write_copy      (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *framebuf,
+                              GError       **error);
+gboolean fli_write_lc        (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *old_framebuf,
+                              guchar        *framebuf,
+                              GError       **error);
+gboolean fli_write_lc_2      (FILE          *f,
+                              s_fli_header  *fli_header,
+                              guchar        *old_framebuf,
+                              guchar        *framebuf,
+                              GError       **error);
 
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]